Skip to content

Instantly share code, notes, and snippets.

@yakipote
Created April 21, 2017 02:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yakipote/681e156f1a82b0b22ecec32330587502 to your computer and use it in GitHub Desktop.
Save yakipote/681e156f1a82b0b22ecec32330587502 to your computer and use it in GitHub Desktop.
Golnag pre-commit lint, vet , test
# 変更のあったgoファイルを取得
# なければ終了
gofiles=$(git diff --cached --name-only --diff-filter=ACM | grep '\.go$'|grep -v mock)
[ -z "$gofiles" ] && exit 0
# 各種コメントを実行して、終了コードを取得
echo $gofiles|xargs -n 1 golint -set_exit_status
lint=$?
echo $gofiles|xargs -n 1 go vet
vet=$?
echo ./${gofiles%%/*}|xargs -n 2 go test
test=$?
exit $(($vet|$lint|$test))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment