You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d229faf
Browse filesBrowse the repository at this point in the historyBrowse files
# Go hooks run the tools on the PATH: gofmt and go from the Go toolchain,
47
+
# goimports and golangci-lint at the versions zz_generated.pre-commit.yaml installs.
48
+
# They replace the archived dnephin/pre-commit-golang and keep its behaviour.
49
+
- repo: local
49
50
hooks:
50
51
- id: go-fmt
52
+
name: go fmt
53
+
language: system
54
+
files: '\.go$'
55
+
entry: >-
56
+
bash -c 'command -v gofmt > /dev/null || { echo "gofmt not installed or available in the PATH, see https://go.dev/doc/install"; exit 1; };
57
+
out="$(gofmt -l -w "$@")"; rc=$?;
58
+
[ -z "$out" ] || echo "$out";
59
+
[ $rc -eq 0 ] && [ -z "$out" ]' --
51
60
- id: go-mod-tidy
61
+
name: go mod tidy
62
+
language: system
63
+
files: '\.go$'
64
+
pass_filenames: false
65
+
entry: >-
66
+
bash -c 'if go mod tidy -v 2>&1 | grep -q "updates to go.mod needed"; then exit 1; fi;
67
+
git diff --exit-code go.* > /dev/null 2>&1;
68
+
if [ $? -eq 1 ]; then echo "go.mod or go.sum differs, please re-add it to your commit"; exit 1; fi' --
52
69
- id: golangci-lint
70
+
name: golangci-lint
71
+
language: system
72
+
types: [go]
73
+
pass_filenames: false
74
+
entry: golangci-lint run
53
75
args:
54
76
# Let independent sessions and worktrees lint at the same time.
55
77
- --allow-parallel-runners
@@ -59,6 +81,14 @@ repos:
59
81
- --max-same-issues=0
60
82
- --max-issues-per-linter=0
61
83
- id: go-imports
84
+
name: go imports
85
+
language: system
86
+
files: '\.go$'
87
+
entry: >-
88
+
bash -c 'command -v goimports > /dev/null || { echo "goimports not installed or available in the PATH, see https://pkg.go.dev/golang.org/x/tools/cmd/goimports"; exit 1; };
0 commit comments