Skip to content

Instantly share code, notes, and snippets.

@ozaydinb
Created October 14, 2019 11:46
Show Gist options
  • Save ozaydinb/066bf661428e6a344814f314c584a96f to your computer and use it in GitHub Desktop.
Save ozaydinb/066bf661428e6a344814f314c584a96f 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
echo "running tests before commiting go files"
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