blob: 316004400b898728e3618144bc2e9934e2168604 [file] [log] [blame]
Girish Gowdra390f12f2021-07-01 15:53:49 -07001# Directory to put `go install`ed binaries in.
2export GOBIN ?= $(shell pwd)/bin
Girish Gowdra64503432020-01-07 10:59:10 +05303
4GO_FILES := $(shell \
5 find . '(' -path '*/.*' -o -path './vendor' ')' -prune \
6 -o -name '*.go' -print | cut -b3-)
7
Girish Gowdra64503432020-01-07 10:59:10 +05308.PHONY: build
9build:
Girish Gowdra390f12f2021-07-01 15:53:49 -070010 go build ./...
Girish Gowdra64503432020-01-07 10:59:10 +053011
12.PHONY: test
13test:
Girish Gowdra390f12f2021-07-01 15:53:49 -070014 go test -race ./...
Girish Gowdra64503432020-01-07 10:59:10 +053015
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
Girish Gowdra64503432020-01-07 10:59:10 +053022.PHONY: golint
23golint:
Girish Gowdra390f12f2021-07-01 15:53:49 -070024 @cd tools && go install golang.org/x/lint/golint
25 @$(GOBIN)/golint ./...
Girish Gowdra64503432020-01-07 10:59:10 +053026
27.PHONY: staticcheck
28staticcheck:
Girish Gowdra390f12f2021-07-01 15:53:49 -070029 @cd tools && go install honnef.co/go/tools/cmd/staticcheck
30 @$(GOBIN)/staticcheck ./...
Girish Gowdra64503432020-01-07 10:59:10 +053031
32.PHONY: lint
Girish Gowdra390f12f2021-07-01 15:53:49 -070033lint: gofmt golint staticcheck
Girish Gowdra64503432020-01-07 10:59:10 +053034
35.PHONY: cover
36cover:
Girish Gowdra390f12f2021-07-01 15:53:49 -070037 go test -coverprofile=cover.out -coverpkg=./... -v ./...
Girish Gowdra64503432020-01-07 10:59:10 +053038 go tool cover -html=cover.out -o cover.html
39
40update-license:
Girish Gowdra390f12f2021-07-01 15:53:49 -070041 @cd tools && go install go.uber.org/tools/update-license
42 @$(GOBIN)/update-license $(GO_FILES)