refactor: check gofmt error. (#203)
This commit is contained in:
parent
590a44209d
commit
9b793cf80b
23
Makefile
23
Makefile
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue