11.PHONY : checks
2- checks : licensecheck gofmt goimports govet misspell ineffassign staticcheck protos-lint buf-format
2+ checks : licensecheck gofmt goimports govet gofix misspell ineffassign staticcheck protos-lint buf-format
33
44.PHONY : licensecheck
55licensecheck :
66 @echo Running license check
7- @find . -path ' ./.git' -prune -o -name ' *.go' -not -name ' *.pb.go' -print | xargs addlicense -check || (echo " Missing license headers" ; exit 1)
7+ @for dir in $(GO_MODULES ) ; do \
8+ echo " Checking licenses in module: $$ dir" ; \
9+ (cd $$ dir && find . -path ' ./.git' -prune -o -name ' *.go' -not -name ' *.pb.go' -print | xargs addlicense -check) || (echo " Missing license headers in $$ dir" ; exit 1); \
10+ done
811
912.PHONY : gofmt
1013gofmt :
1114 @echo Running gofmt
12- @{ \
13- OUTPUT=" $$ (find . -path './.git' -prune -o -name '*.go' -not -name '*.pb.go' -print | xargs gofmt -l -s || true)" ; \
14- if [ -n " $$ OUTPUT" ]; then \
15- echo " The following gofmt issues were flagged:" ; \
16- echo " $$ OUTPUT" ; \
17- echo " The gofmt command 'gofmt -l -s -w' must be run for these files" ; \
18- exit 1; \
19- fi \
20- }
15+ @for dir in $(GO_MODULES ) ; do \
16+ echo " Checking format in module: $$ dir" ; \
17+ (cd $$ dir && { \
18+ OUTPUT=" $$ (find . -path './.git' -prune -o -name '*.go' -not -name '*.pb.go' -print | xargs gofmt -l -s || true)" ; \
19+ if [ -n " $$ OUTPUT" ]; then \
20+ echo " The following gofmt issues were flagged in $$ dir:" ; \
21+ echo " $$ OUTPUT" ; \
22+ echo " The gofmt command 'gofmt -l -s -w' must be run for these files" ; \
23+ exit 1; \
24+ fi ; \
25+ }) || exit 1; \
26+ done
2127
2228.PHONY : goimports
2329goimports :
2430 @echo Running goimports
25- @{ \
26- OUTPUT=" $$ (find . -path './.git' -prune -o -name '*.go' -not -name '*.pb.go' -print | xargs goimports -l || true)" ; \
27- if [ -n " $$ OUTPUT" ]; then \
28- echo "The following files contain goimports errors"; \
29- echo "$$OUTPUT"; \
30- echo "The goimports command 'goimports -l -w' must be run for these files"; \
31- exit 1; \
32- fi \
33- }
31+ @for dir in $(GO_MODULES ) ; do \
32+ echo " Checking imports in module: $$ dir" ; \
33+ (cd $$ dir && { \
34+ OUTPUT=" $$ (find . -path './.git' -prune -o -name '*.go' -not -name '*.pb.go' -print | xargs goimports -l || true)" ; \
35+ if [ -n " $$ OUTPUT" ]; then \
36+ echo " The following files contain goimports errors in $$ dir:" ; \
37+ echo " $$ OUTPUT" ; \
38+ echo " The goimports command 'goimports -l -w' must be run for these files" ; \
39+ exit 1; \
40+ fi ; \
41+ }) || exit 1; \
42+ done
3443
3544.PHONY : govet
3645govet :
3746 @echo Running go vet
38- @go vet -all $(shell go list -f '{{.Dir}}' ./...) || (echo " Found some issues identified by 'go vet -all'. Please fix them!" ; exit 1; )
47+ @for dir in $(GO_MODULES ) ; do \
48+ echo " Checking module: $$ dir" ; \
49+ (cd $$ dir && go vet -all $$ (go list ./...)) || exit 1; \
50+ done
51+
52+ .PHONY : gofix
53+ gofix :
54+ @echo Running go fix
55+ @for dir in $(GO_MODULES ) ; do \
56+ echo " Checking module: $$ dir" ; \
57+ (cd $$ dir && { \
58+ OUTPUT=" $$ (go fix -diff ./... 2>&1 | grep -v '^go: warning:' | grep -v '^no packages to fix')" ; \
59+ if [ -n " $$ OUTPUT" ]; then \
60+ echo " go fix found modernization opportunities in $$ dir:" ; \
61+ echo " $$ OUTPUT" ; \
62+ echo " " ; \
63+ echo " Run 'make gofix-apply' to apply these changes automatically." ; \
64+ exit 1; \
65+ fi ; \
66+ }) || exit 1; \
67+ done
68+ @echo " ✓ No go fix suggestions - code is up to date."
69+
70+ .PHONY : gofix-apply
71+ gofix-apply :
72+ @echo Applying go fix to all modules
73+ @for dir in $(GO_MODULES ) ; do \
74+ echo " Applying fixes to module: $$ dir" ; \
75+ (cd $$ dir && go fix ./...); \
76+ done
77+ @echo " ✓ go fix applied to all modules."
3978
4079.PHONY : misspell
4180misspell :
4281 @echo Running misspell
43- @{ \
44- OUTPUT=" $$ (find . -path './.git' -prune -o -type f -print | grep -v '.golangci.yml' | grep -v 'testdata' | xargs misspell || true)" ; \
45- if [ -n " $$ OUTPUT" ]; then \
46- echo " The following files are have spelling errors:" ; \
47- echo " $$ OUTPUT" ; \
48- exit 1; \
49- fi \
50- }
82+ @for dir in $(GO_MODULES ) ; do \
83+ echo " Checking spelling in module: $$ dir" ; \
84+ (cd $$ dir && { \
85+ OUTPUT=" $$ (find . -path './.git' -prune -o -type f -print | grep -v '.golangci.yml' | grep -v 'testdata' | xargs misspell || true)" ; \
86+ if [ -n " $$ OUTPUT" ]; then \
87+ echo " The following files in $$ dir have spelling errors:" ; \
88+ echo " $$ OUTPUT" ; \
89+ exit 1; \
90+ fi ; \
91+ }) || exit 1; \
92+ done
5193
5294.PHONY : staticcheck
5395staticcheck :
5496 @echo Running staticcheck
55- @{ \
56- OUTPUT=" $$ (staticcheck -tests=false ./... | grep -v .pb.go || true)" ; \
57- if [ -n " $$ OUTPUT" ]; then \
58- echo " The following staticcheck issues were flagged:" ; \
59- echo " $$ OUTPUT" ; \
60- exit 1; \
61- fi \
62- }
97+ @for dir in $(GO_MODULES ) ; do \
98+ echo " Checking module: $$ dir" ; \
99+ (cd $$ dir && { \
100+ OUTPUT=" $$ (staticcheck -tests=false ./... | grep -v .pb.go || true)" ; \
101+ if [ -n " $$ OUTPUT" ]; then \
102+ echo " The following staticcheck issues were flagged in $$ dir:" ; \
103+ echo " $$ OUTPUT" ; \
104+ exit 1; \
105+ fi ; \
106+ }) || exit 1; \
107+ done
63108
64109.PHONY : gocyclo
65110gocyclo :
@@ -69,7 +114,10 @@ gocyclo:
69114.PHONY : ineffassign
70115ineffassign :
71116 @echo Running ineffassign
72- @ineffassign $(shell go list -f '{{.Dir}}' ./...)
117+ @for dir in $(GO_MODULES ) ; do \
118+ echo " Checking module: $$ dir" ; \
119+ (cd $$ dir && ineffassign $$ (go list -f ' {{.Dir}}' ./...)) || exit 1; \
120+ done
73121
74122.PHONY : protos-lint
75123protos-lint :
0 commit comments