Last active
June 23, 2016 19:30
-
-
Save reedobrien/1ba37bcd855e99b57b64 to your computer and use it in GitHub Desktop.
git pre-push hook for go proj
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/bash | |
set -e | |
# find all un-gofmt'd go files | |
unformatted=$(goimports -l -e .) | |
# if there are un-gofmt'd go files | |
if [ -n "$unformatted" ]; then | |
# print warnings and fail | |
echo >&2 "Go files must be formatted with goimports. Please run:" | |
for filename in $unformatted; do | |
echo >&2 "goimports -w $PWD/$filename" | |
done | |
exit 1 | |
fi | |
# run go vet w/ go tool to check that the code can be built, etc. | |
echo "running go vet..." | |
go vet ./... | |
echo "...OK" | |
# check this build w/ the go build race detector | |
#go build -race $SOMEDIR | |
# make sure deps are set | |
# TODO: choose how to manage dependencies | |
# run go tests | |
echo "running go test..." | |
go test ./... | |
echo "...OK" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment