Skip to content

Commit 50f62dc

Browse files
committed
testing go vet in pre-commit
1 parent 0bd978c commit 50f62dc

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

‎git-hooks/pre-commit‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,23 @@ check_go_fmt() {
2727
exit 1
2828
}
2929

30+
check_go_vet() {
31+
gofiles=$(git diff --cached --name-only --diff-filter=ACM | grep '.go$')
32+
[ -z "$gofiles" ] && return 0
33+
34+
warnings=$(go vet $gofiles 2>&1 | grep -v -e 'possible formatting directive' -e 'should have signature WriteTo' -e 'exit status 1')
35+
[ -z "$warnings" ] && return 0
36+
37+
# go vet found issues
38+
39+
echo >&2 "go vet found issues:"
40+
for msg in $warnings; do
41+
echo >&2 $msg
42+
done
43+
44+
exit 1
45+
}
46+
3047
#
3148
# report bad files and die if there are any
3249
#
@@ -119,3 +136,4 @@ fi
119136

120137
# checkLineLength
121138
check_go_fmt
139+
check_go_vet

‎go/engine/signup_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func TestSignupEngine(t *testing.T) {
5353
t.Fatal(err)
5454
}
5555

56-
sui := libkb.TestSecretUI{Passphrase: fu.Passphrase}
56+
sui := libkb.TestSecretUI{fu.Passphrase}
5757
if err = G.LoginState.PubkeyLogin("", sui); err != nil {
5858
t.Fatal(err)
5959
}

0 commit comments

Comments
 (0)