Created
April 21, 2017 02:56
-
-
Save yakipote/681e156f1a82b0b22ecec32330587502 to your computer and use it in GitHub Desktop.
Golnag pre-commit lint, vet , test
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
# 変更のあった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