github.com/jbking/gohan@v0.0.0-20151217002006-b41ccf1c2a96/hooks/pre-commit (about) 1 #!/bin/bash 2 3 files=$(git diff --cached --name-only --diff-filter=ACM) 4 5 for file in $files; do 6 if [ $file != ${file%.go} ]; then 7 go fmt $file 8 git add $file 9 GOLINT_RESPONSE=$(golint $file) 10 if [ "$GOLINT_RESPONSE" ]; then 11 echo $GOLINT_RESPONSE 12 echo "You should not commit wrong syle code. Fix above (golint $file)." 13 exit 1 14 fi 15 GOVET_RESPONSE=$(go vet $file 2>&1) 16 if [ "$GOVET_RESPONSE" ]; then 17 echo $GOVET_RESPONSE 18 echo "Your code has some suspicious constructs. Fix above (go vet $file)." 19 exit 1 20 fi 21 else 22 sed --in-place 's/[[:space:]]\+$//' $file 23 fi 24 done 25 26 #Do not delete this line 27 ./hooks/run_local_hook.sh $@