blob: 316004400b898728e3618144bc2e9934e2168604 [file] [log] [blame]
Elia Battistonc8d0d462022-02-22 16:30:51 +01001# Directory to put `go install`ed binaries in.
2export GOBIN ?= $(shell pwd)/bin
3
4GO_FILES := $(shell \
5 find . '(' -path '*/.*' -o -path './vendor' ')' -prune \
6 -o -name '*.go' -print | cut -b3-)
7
8.PHONY: build
9build:
10 go build ./...
11
12.PHONY: test
13test:
14 go test -race ./...
15
16.PHONY: gofmt
17gofmt:
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
22.PHONY: golint
23golint:
24 @cd tools && go install golang.org/x/lint/golint
25 @$(GOBIN)/golint ./...
26
27.PHONY: staticcheck
28staticcheck:
29 @cd tools && go install honnef.co/go/tools/cmd/staticcheck
30 @$(GOBIN)/staticcheck ./...
31
32.PHONY: lint
33lint: gofmt golint staticcheck
34
35.PHONY: cover
36cover:
37 go test -coverprofile=cover.out -coverpkg=./... -v ./...
38 go tool cover -html=cover.out -o cover.html
39
40update-license:
41 @cd tools && go install go.uber.org/tools/update-license
42 @$(GOBIN)/update-license $(GO_FILES)