Makefile 664 B

1234567891011121314151617181920212223242526272829303132333435
  1. # Directory to place `go install`ed binaries into.
  2. export GOBIN ?= $(shell pwd)/bin
  3. GOLINT = $(GOBIN)/golint
  4. GO_FILES ?= *.go
  5. .PHONY: build
  6. build:
  7. go build ./...
  8. .PHONY: test
  9. test:
  10. go test -race ./...
  11. .PHONY: gofmt
  12. gofmt:
  13. $(eval FMT_LOG := $(shell mktemp -t gofmt.XXXXX))
  14. gofmt -e -s -l $(GO_FILES) > $(FMT_LOG) || true
  15. @[ ! -s "$(FMT_LOG)" ] || (echo "gofmt failed:" && cat $(FMT_LOG) && false)
  16. $(GOLINT):
  17. go install golang.org/x/lint/golint
  18. .PHONY: golint
  19. golint: $(GOLINT)
  20. $(GOLINT) ./...
  21. .PHONY: lint
  22. lint: gofmt golint
  23. .PHONY: cover
  24. cover:
  25. go test -coverprofile=cover.out -coverpkg ./... -v ./...
  26. go tool cover -html=cover.out -o cover.html