blob: 316004400b898728e3618144bc2e9934e2168604 [file] [log] [blame]
khenaidoo106c61a2021-08-11 18:05:46 -04001# Directory to put `go install`ed binaries in.
2export GOBIN ?= $(shell pwd)/bin
William Kurkianea869482019-04-09 15:16:11 -04003
4GO_FILES := $(shell \
5 find . '(' -path '*/.*' -o -path './vendor' ')' -prune \
6 -o -name '*.go' -print | cut -b3-)
7
William Kurkianea869482019-04-09 15:16:11 -04008.PHONY: build
9build:
khenaidoo106c61a2021-08-11 18:05:46 -040010 go build ./...
William Kurkianea869482019-04-09 15:16:11 -040011
12.PHONY: test
13test:
khenaidoo106c61a2021-08-11 18:05:46 -040014 go test -race ./...
William Kurkianea869482019-04-09 15:16:11 -040015
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
William Kurkianea869482019-04-09 15:16:11 -040022.PHONY: golint
23golint:
khenaidoo106c61a2021-08-11 18:05:46 -040024 @cd tools && go install golang.org/x/lint/golint
25 @$(GOBIN)/golint ./...
William Kurkianea869482019-04-09 15:16:11 -040026
27.PHONY: staticcheck
28staticcheck:
khenaidoo106c61a2021-08-11 18:05:46 -040029 @cd tools && go install honnef.co/go/tools/cmd/staticcheck
30 @$(GOBIN)/staticcheck ./...
William Kurkianea869482019-04-09 15:16:11 -040031
32.PHONY: lint
khenaidoo106c61a2021-08-11 18:05:46 -040033lint: gofmt golint staticcheck
William Kurkianea869482019-04-09 15:16:11 -040034
35.PHONY: cover
36cover:
khenaidoo106c61a2021-08-11 18:05:46 -040037 go test -coverprofile=cover.out -coverpkg=./... -v ./...
William Kurkianea869482019-04-09 15:16:11 -040038 go tool cover -html=cover.out -o cover.html
39
40update-license:
khenaidoo106c61a2021-08-11 18:05:46 -040041 @cd tools && go install go.uber.org/tools/update-license
42 @$(GOBIN)/update-license $(GO_FILES)