Makefile 1.1 KB

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