2021-01-25 05:07:35 +05:30
|
|
|
# Directory to put `go install`ed binaries in.
|
|
|
|
export GOBIN ?= $(shell pwd)/bin
|
|
|
|
|
|
|
|
GO_FILES := $(shell \
|
|
|
|
find . '(' -path '*/.*' -o -path './vendor' ')' -prune \
|
|
|
|
-o -name '*.go' -print | cut -b3-)
|
|
|
|
|
|
|
|
.PHONY: build
|
|
|
|
build:
|
|
|
|
go build ./...
|
|
|
|
|
|
|
|
.PHONY: test
|
|
|
|
test:
|
|
|
|
go test -race ./...
|
|
|
|
|
|
|
|
.PHONY: gofmt
|
|
|
|
gofmt:
|
|
|
|
$(eval FMT_LOG := $(shell mktemp -t gofmt.XXXXX))
|
|
|
|
@gofmt -e -s -l $(GO_FILES) > $(FMT_LOG) || true
|
|
|
|
@[ ! -s "$(FMT_LOG)" ] || (echo "gofmt failed:" | cat - $(FMT_LOG) && false)
|
|
|
|
|
|
|
|
.PHONY: golint
|
|
|
|
golint:
|
2021-03-01 04:38:33 +05:30
|
|
|
@cd tools && go install golang.org/x/lint/golint
|
2021-01-25 05:07:35 +05:30
|
|
|
@$(GOBIN)/golint ./...
|
|
|
|
|
|
|
|
.PHONY: staticcheck
|
|
|
|
staticcheck:
|
2021-03-01 04:38:33 +05:30
|
|
|
@cd tools && go install honnef.co/go/tools/cmd/staticcheck
|
2021-01-25 05:07:35 +05:30
|
|
|
@$(GOBIN)/staticcheck ./...
|
|
|
|
|
|
|
|
.PHONY: lint
|
|
|
|
lint: gofmt golint staticcheck
|
|
|
|
|
|
|
|
.PHONY: cover
|
|
|
|
cover:
|
|
|
|
go test -coverprofile=cover.out -coverpkg=./... -v ./...
|
|
|
|
go tool cover -html=cover.out -o cover.html
|
|
|
|
|
|
|
|
update-license:
|
2021-03-01 04:38:33 +05:30
|
|
|
@cd tools && go install go.uber.org/tools/update-license
|
2021-01-25 05:07:35 +05:30
|
|
|
@$(GOBIN)/update-license $(GO_FILES)
|