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