refactor: update gofmt check (#233)

This commit is contained in:
Bo-Yi Wu 2017-06-04 21:26:45 -05:00 committed by GitHub
parent 5651d9e51f
commit fb7109835a
1 changed files with 6 additions and 5 deletions

View File

@ -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,14 +42,15 @@ 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;