refactor: check gofmt error. (#203)

This commit is contained in:
Bo-Yi Wu 2017-04-01 22:30:46 +08:00 committed by GitHub
parent 590a44209d
commit 9b793cf80b
1 changed files with 9 additions and 14 deletions

View File

@ -5,10 +5,12 @@ EXECUTABLE := gorush
DEPLOY_ACCOUNT := appleboy
DEPLOY_IMAGE := $(EXECUTABLE)
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/*"
SOURCES ?= $(shell find . -name "*.go" -type f)
TAGS ?=
LDFLAGS ?= -X 'main.Version=$(VERSION)'
@ -39,23 +41,16 @@ endif
@echo "Already set ANDROID_API_KEY and ANDROID_TEST_TOKEN globale variable."
fmt:
find . -name "*.go" -type f -not -path "./vendor/*" | xargs gofmt -s -w
$(GOFILES) | xargs $(GOFMT) -w
.PHONY: fmt-check
fmt-check:
@if git diff --quiet --exit-code; then \
$(MAKE) fmt && git diff --exit-code || { \
git checkout .; \
echo; \
echo "Please run 'make fmt' and commit the result"; \
echo; \
false; } >&2; \
else { \
echo; \
echo "'make fmt-check' cannot be run with unstaged changes"; \
echo; \
false; } >&2; \
fi
# get all go files and run go fmt on them
@files=$$($(GOFILES) | xargs $(GOFMT) -l); if [ -n "$$files" ]; then \
echo "Please run 'make fmt' and commit the result:"; \
echo "$${files}"; \
exit 1; \
fi;
vet:
go vet $(PACKAGES)