Skip to content

Instantly share code, notes, and snippets.

@ngurajeka
Created March 28, 2017 12:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ngurajeka/3508bdd23dd874c6a62c1d499587c0c4 to your computer and use it in GitHub Desktop.
Save ngurajeka/3508bdd23dd874c6a62c1d499587c0c4 to your computer and use it in GitHub Desktop.
#!/bin/sh
gofiles=$(git diff --cached --name-only --diff-filter=ACM | grep '\.go$')
[ -z "$gofiles" ] && exit 0
unformatted=$(gofmt -l $gofiles)
[ -z "$unformatted" ] || echo "needs formatting: $unformatted"
# tests
go test -v -race $(go list ./... | grep -v /vendor/)
RESULT=$?
[ $RESULT -ne 0 ] && exit 1
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment