feat: add fmt check command. (#202)
This commit is contained in:
parent
5b2b3695e5
commit
590a44209d
18
Makefile
18
Makefile
|
@ -41,6 +41,22 @@ endif
|
||||||
fmt:
|
fmt:
|
||||||
find . -name "*.go" -type f -not -path "./vendor/*" | xargs gofmt -s -w
|
find . -name "*.go" -type f -not -path "./vendor/*" | xargs gofmt -s -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
|
||||||
|
|
||||||
vet:
|
vet:
|
||||||
go vet $(PACKAGES)
|
go vet $(PACKAGES)
|
||||||
|
|
||||||
|
@ -76,7 +92,7 @@ build: $(EXECUTABLE)
|
||||||
$(EXECUTABLE): $(SOURCES)
|
$(EXECUTABLE): $(SOURCES)
|
||||||
go build -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o bin/$@
|
go build -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o bin/$@
|
||||||
|
|
||||||
test:
|
test: fmt-check
|
||||||
for PKG in $(PACKAGES); do go test -v -cover -coverprofile $$GOPATH/src/$$PKG/coverage.txt $$PKG || exit 1; done;
|
for PKG in $(PACKAGES); do go test -v -cover -coverprofile $$GOPATH/src/$$PKG/coverage.txt $$PKG || exit 1; done;
|
||||||
|
|
||||||
redis_test: init
|
redis_test: init
|
||||||
|
|
Loading…
Reference in New Issue