Makefile 945 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # Directory to put `go install`ed binaries in.
  2. export GOBIN ?= $(shell pwd)/bin
  3. GO_FILES := $(shell \
  4. find . '(' -path '*/.*' -o -path './vendor' ')' -prune \
  5. -o -name '*.go' -print | cut -b3-)
  6. .PHONY: build
  7. build:
  8. go build ./...
  9. .PHONY: test
  10. test:
  11. go test -race ./...
  12. .PHONY: gofmt
  13. gofmt:
  14. $(eval FMT_LOG := $(shell mktemp -t gofmt.XXXXX))
  15. @gofmt -e -s -l $(GO_FILES) > $(FMT_LOG) || true
  16. @[ ! -s "$(FMT_LOG)" ] || (echo "gofmt failed:" | cat - $(FMT_LOG) && false)
  17. .PHONY: golint
  18. golint:
  19. @go install golang.org/x/lint/golint
  20. @$(GOBIN)/golint ./...
  21. .PHONY: staticcheck
  22. staticcheck:
  23. @go install honnef.co/go/tools/cmd/staticcheck
  24. @$(GOBIN)/staticcheck ./...
  25. .PHONY: lint
  26. lint: gofmt golint staticcheck
  27. .PHONY: cover
  28. cover:
  29. go test -coverprofile=cover.out -coverpkg=./... -v ./...
  30. go tool cover -html=cover.out -o cover.html
  31. update-license:
  32. @go install go.uber.org/tools/update-license
  33. @$(GOBIN)/update-license $(GO_FILES)