From 275a08636f832aa67375d1abf957a25707833eae Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Fri, 20 Jul 2018 09:43:09 +0200 Subject: [PATCH] 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. --- Makefile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 95cc13b7..621cec71 100644 --- a/Makefile +++ b/Makefile @@ -39,11 +39,12 @@ push: container docker push $(IMAGE_NAME):$(IMAGE_VERSION) test: - if ! [ $$(go fmt $$(go list ./... | grep -v vendor) | wc -l) -eq 0 ]; then \ - echo "formatting errors:"; \ - go fmt $$(go list ./... | grep -v vendor); \ - false; \ - fi + files=$$(find ./ -name '*.go' | grep -v '^./vendor' ); \ + if [ $$(gofmt -d $$files | wc -l) -ne 0 ]; then \ + echo "formatting errors:"; \ + gofmt -d $$files; \ + false; \ + fi go vet $$(go list ./... | grep -v vendor) go test $$(go list ./... | grep -v vendor | grep -v "cmd/csi-sanity") ./hack/e2e.sh