Created
October 14, 2019 11:46
-
-
Save ozaydinb/066bf661428e6a344814f314c584a96f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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