From fb7109835a5849cb6d5d6b35ba74c77250247a13 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Sun, 4 Jun 2017 21:26:45 -0500 Subject: [PATCH] refactor: update gofmt check (#233) --- Makefile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index c027b86..ec71cbd 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ GOFMT ?= gofmt "-s" TARGETS ?= linux darwin windows ARCHS ?= amd64 386 PACKAGES ?= $(shell go list ./... | grep -v /vendor/) -GOFILES := find . -name "*.go" -type f -not -path "./vendor/*" +GOFILES := $(shell find . -name "*.go" -type f -not -path "./vendor/*") SOURCES ?= $(shell find . -name "*.go" -type f) TAGS ?= LDFLAGS ?= -X 'main.Version=$(VERSION)' @@ -42,16 +42,17 @@ endif @echo "Already set ANDROID_API_KEY and ANDROID_TEST_TOKEN globale variable." fmt: - $(GOFILES) | xargs $(GOFMT) -w + $(GOFMT) -w $(GOFILES) .PHONY: fmt-check fmt-check: # get all go files and run go fmt on them - @files=$$($(GOFILES) | xargs $(GOFMT) -l); if [ -n "$$files" ]; then \ + @diff=$$($(GOFMT) -d $(GOFILES)); \ + if [ -n "$$diff" ]; then \ echo "Please run 'make fmt' and commit the result:"; \ - echo "$${files}"; \ + echo "$${diff}"; \ exit 1; \ - fi; + fi; vet: go vet $(PACKAGES)