diff --git a/.travis.yml b/.travis.yml index 56bc01a..815a773 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,6 +27,7 @@ before-install: - nvm use stable - cd service/ && go get -u -v -d && cd .. - cd tests/ && npm install && npm install chromedriver geckodriver && cd .. + - gofmt -l . script: @@ -36,10 +37,9 @@ script: - npm install -g http-server mocha eslint - eslint view/web/app-jarvis.js - echo "checking go format ..." - - diff -u <(echo -n) <(gofmt -d ./src ./tsdb) - - echo "perfect go format. moving ahead ..." + - build/scripts/gofmt.sh - cd view/web/ && npm start && cd ../.. - go test service/controllers/controllers_test.go - cd tests/ - npm install - - xvfb-run -s "-screen 0 1920x1080x16" -a mocha test.js \ No newline at end of file + - xvfb-run -s "-screen 0 1920x1080x16" -a mocha test.js diff --git a/build/scripts/gofmt.sh b/build/scripts/gofmt.sh new file mode 100755 index 0000000..8aae7bf --- /dev/null +++ b/build/scripts/gofmt.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +echo 'running go fmt on all packages...' +invalidFiles=$(gofmt -l . 2>&1) +if [ "$invalidFiles" ]; then + echo "These files did not pass the 'go fmt' check, please run 'go fmt' on them:" + echo $invalidFiles + exit 1 +fi diff --git a/service/controllers/controllers.go b/service/controllers/controllers.go index 9aefd4a..e4c85a6 100644 --- a/service/controllers/controllers.go +++ b/service/controllers/controllers.go @@ -36,7 +36,7 @@ func MessagesController(w http.ResponseWriter, r *http.Request) { func filterForSpeech(s string) string { - s = strings.Replace(s, "?", " ", -1) + s = strings.Replace(s, "?", " ", -1) s = strings.Replace(s, "%", " ", -1) s = strings.Replace(s, "#", " ", -1) s = strings.Replace(s, "$", " ", -1) @@ -367,7 +367,7 @@ func scrapeYahoo(query string) []messageQueryBody { } var resultObj []messageQueryBody listArray := doc.Find("div#web > ol") - if len(listArray.Nodes) <= 0{ + if len(listArray.Nodes) <= 0 { logger.Error(errors.New("Unable to find