2018-10-14 07:39:16 +03:00
|
|
|
GO ?= go
|
2017-06-13 05:50:42 +03:00
|
|
|
GOFMT ?= gofmt "-s"
|
2018-10-14 07:39:16 +03:00
|
|
|
PACKAGES ?= $(shell $(GO) list ./... | grep -v /vendor/)
|
|
|
|
VETPACKAGES ?= $(shell $(GO) list ./... | grep -v /vendor/ | grep -v /examples/)
|
2017-06-13 05:50:42 +03:00
|
|
|
GOFILES := $(shell find . -name "*.go" -type f -not -path "./vendor/*")
|
2018-10-14 07:39:16 +03:00
|
|
|
TESTFOLDER := $(shell $(GO) list ./... | grep -E 'gin$$|binding$$|render$$' | grep -v examples)
|
2017-06-13 05:50:42 +03:00
|
|
|
|
2018-01-24 06:06:42 +03:00
|
|
|
all: install
|
2017-06-13 05:50:42 +03:00
|
|
|
|
|
|
|
install: deps
|
|
|
|
govendor sync
|
|
|
|
|
|
|
|
.PHONY: test
|
|
|
|
test:
|
2018-10-14 07:39:16 +03:00
|
|
|
echo "mode: count" > coverage.out
|
|
|
|
for d in $(TESTFOLDER); do \
|
|
|
|
$(GO) test -v -covermode=count -coverprofile=profile.out $$d; \
|
|
|
|
if [ -f profile.out ]; then \
|
|
|
|
cat profile.out | grep -v "mode:" >> coverage.out; \
|
|
|
|
rm profile.out; \
|
|
|
|
fi; \
|
|
|
|
done
|
2017-06-13 05:50:42 +03:00
|
|
|
|
|
|
|
.PHONY: fmt
|
|
|
|
fmt:
|
|
|
|
$(GOFMT) -w $(GOFILES)
|
|
|
|
|
|
|
|
.PHONY: fmt-check
|
|
|
|
fmt-check:
|
|
|
|
@diff=$$($(GOFMT) -d $(GOFILES)); \
|
|
|
|
if [ -n "$$diff" ]; then \
|
|
|
|
echo "Please run 'make fmt' and commit the result:"; \
|
|
|
|
echo "$${diff}"; \
|
|
|
|
exit 1; \
|
|
|
|
fi;
|
|
|
|
|
|
|
|
vet:
|
2018-10-14 07:39:16 +03:00
|
|
|
$(GO) vet $(VETPACKAGES)
|
2017-06-13 05:50:42 +03:00
|
|
|
|
|
|
|
deps:
|
|
|
|
@hash govendor > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
2018-10-14 07:39:16 +03:00
|
|
|
$(GO) get -u github.com/kardianos/govendor; \
|
2017-06-13 05:50:42 +03:00
|
|
|
fi
|
|
|
|
@hash embedmd > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
2018-10-14 07:39:16 +03:00
|
|
|
$(GO) get -u github.com/campoy/embedmd; \
|
2017-06-13 05:50:42 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
embedmd:
|
|
|
|
embedmd -d *.md
|
|
|
|
|
|
|
|
.PHONY: lint
|
|
|
|
lint:
|
|
|
|
@hash golint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
2018-10-14 07:39:16 +03:00
|
|
|
$(GO) get -u golang.org/x/lint/golint; \
|
2017-06-13 05:50:42 +03:00
|
|
|
fi
|
|
|
|
for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done;
|
|
|
|
|
|
|
|
.PHONY: misspell-check
|
|
|
|
misspell-check:
|
|
|
|
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
2018-10-14 07:39:16 +03:00
|
|
|
$(GO) get -u github.com/client9/misspell/cmd/misspell; \
|
2017-06-13 05:50:42 +03:00
|
|
|
fi
|
|
|
|
misspell -error $(GOFILES)
|
|
|
|
|
|
|
|
.PHONY: misspell
|
|
|
|
misspell:
|
|
|
|
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
2018-10-14 07:39:16 +03:00
|
|
|
$(GO) get -u github.com/client9/misspell/cmd/misspell; \
|
2017-06-13 05:50:42 +03:00
|
|
|
fi
|
|
|
|
misspell -w $(GOFILES)
|