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