Skip to content

Commit 9a44b3f

Browse files
pohlylpabon
authored andcommitted
Makefile: fix format error reporting
"go fmt" always fixes code in place. As a result, running it again to report formatting errors doesn't do anything. The original intention probably was to check for errors and then report them. This is what is done now, using gofmt directly and it's diff output mode.
1 parent 2406913 commit 9a44b3f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Makefile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ push: container
3939
docker push $(IMAGE_NAME):$(IMAGE_VERSION)
4040

4141
test:
42-
if ! [ $$(go fmt $$(go list ./... | grep -v vendor) | wc -l) -eq 0 ]; then \
43-
echo "formatting errors:"; \
44-
go fmt $$(go list ./... | grep -v vendor); \
45-
false; \
46-
fi
42+
files=$$(find ./ -name '*.go' | grep -v '^./vendor' ); \
43+
if [ $$(gofmt -d $$files | wc -l) -ne 0 ]; then \
44+
echo "formatting errors:"; \
45+
gofmt -d $$files; \
46+
false; \
47+
fi
4748
go vet $$(go list ./... | grep -v vendor)
4849
go test $$(go list ./... | grep -v vendor | grep -v "cmd/csi-sanity")
4950
./hack/e2e.sh

0 commit comments

Comments
 (0)