2019-11-25 20:16:00 +00:00
|
|
|
# Directory to put `go install`ed binaries in.
|
|
|
|
export GOBIN ?= $(shell pwd)/bin
|
2019-07-24 07:58:01 +00:00
|
|
|
|
|
|
|
GO_FILES := $(shell \
|
|
|
|
find . '(' -path '*/.*' -o -path './vendor' ')' -prune \
|
|
|
|
-o -name '*.go' -print | cut -b3-)
|
|
|
|
|
|
|
|
.PHONY: build
|
|
|
|
build:
|
2019-11-25 20:16:00 +00:00
|
|
|
go build ./...
|
2019-07-24 07:58:01 +00:00
|
|
|
|
|
|
|
.PHONY: test
|
|
|
|
test:
|
2019-11-25 20:16:00 +00:00
|
|
|
go test -race ./...
|
2019-07-24 07:58:01 +00:00
|
|
|
|
|
|
|
.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-10-19 13:43:41 +00:00
|
|
|
@cd tools && go install golang.org/x/lint/golint
|
2019-11-25 20:16:00 +00:00
|
|
|
@$(GOBIN)/golint ./...
|
2019-07-24 07:58:01 +00:00
|
|
|
|
|
|
|
.PHONY: staticcheck
|
|
|
|
staticcheck:
|
2021-10-19 13:43:41 +00:00
|
|
|
@cd tools && go install honnef.co/go/tools/cmd/staticcheck
|
2019-11-25 20:16:00 +00:00
|
|
|
@$(GOBIN)/staticcheck ./...
|
2019-07-24 07:58:01 +00:00
|
|
|
|
|
|
|
.PHONY: lint
|
2019-11-25 20:16:00 +00:00
|
|
|
lint: gofmt golint staticcheck
|
2019-07-24 07:58:01 +00:00
|
|
|
|
|
|
|
.PHONY: cover
|
|
|
|
cover:
|
2021-10-19 13:43:41 +00:00
|
|
|
go test -race -coverprofile=cover.out -coverpkg=./... -v ./...
|
2019-07-24 07:58:01 +00:00
|
|
|
go tool cover -html=cover.out -o cover.html
|