Makefile

 1.PHONY: all
 2all: setup lint test
 3
 4.PHONY: test
 5test: setup
 6	go test -bench ./...
 7
 8.PHONY: cover
 9cover: setup
10	mkdir -p coverage
11	gocov test ./... | gocov-html > coverage/coverage.html
12
13sources = $(shell find . -name '*.go' -not -path './vendor/*')
14.PHONY: goimports
15goimports: setup
16	goimports -w $(sources)
17
18.PHONY: lint
19lint: setup
20	gometalinter ./... --enable=goimports --disable=gocyclo --vendor -t
21
22.PHONY: install
23install: setup
24	go install
25
26BIN_DIR := $(GOPATH)/bin
27GOIMPORTS := $(BIN_DIR)/goimports
28GOMETALINTER := $(BIN_DIR)/gometalinter
29DEP := $(BIN_DIR)/dep
30GOCOV := $(BIN_DIR)/gocov
31GOCOV_HTML := $(BIN_DIR)/gocov-html
32
33$(GOIMPORTS):
34	go get -u golang.org/x/tools/cmd/goimports
35
36$(GOMETALINTER):
37	go get -u github.com/alecthomas/gometalinter
38	gometalinter --install &> /dev/null
39
40$(GOCOV):
41	go get -u github.com/axw/gocov/gocov
42
43$(GOCOV_HTML):
44	go get -u gopkg.in/matm/v1/gocov-html
45
46$(DEP):
47	go get -u github.com/golang/dep/cmd/dep
48
49tools: $(GOIMPORTS) $(GOMETALINTER) $(GOCOV) $(GOCOV_HTML) $(DEP)
50
51vendor: $(DEP)
52	dep ensure
53
54setup: tools vendor
55
56updatedeps:
57	dep ensure -update