Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gofmt script to enforce Go formatting #219

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
- xvfb-run -s "-screen 0 1920x1080x16" -a mocha test.js
9 changes: 9 additions & 0 deletions build/scripts/gofmt.sh
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions service/controllers/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 <ol>."))
}
list := listArray.Eq(0)
Expand Down Expand Up @@ -404,4 +404,4 @@ func scrapeYahoo(query string) []messageQueryBody {
resultObj = append(resultObj, resultElement)
}
return resultObj
}
}