Debian Codegraph @

Makefile

raw
1 .DEFAULT_GOAL := help
2
3 SOURCES := $(shell find . -prune -o -name "*.go" -not -name '*_test.go' -print)
4
5 GOIMPORTS ?= goimports
6 GOCILINT ?= golangci-lint
7
8 .PHONY: setup
9 setup: ## Setup for required tools.
10 go get -u golang.org/x/tools/cmd/goimports
11 go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
12 go get -u golang.org/x/tools/cmd/stringer
13
14 .PHONY: fmt
15 fmt: $(SOURCES) ## Formatting source codes.
16 @$(GOIMPORTS) -w $^
17
18 .PHONY: lint
19 lint: ## Run golangci-lint.
20 @$(GOCILINT) run --no-config --disable-all --enable=goimports --enable=misspell ./...
21
22 .PHONY: test
23 test: ## Run tests with race condition checking.
24 @go test -race ./...
25
26 .PHONY: bench
27 bench: ## Run benchmarks.
28 @go test -bench=. -run=- -benchmem ./...
29
30 .PHONY: coverage
31 cover: ## Run the tests.
32 @go test -coverprofile=coverage.o
33 @go tool cover -func=coverage.o
34
35 .PHONY: generate
36 generate: ## Run go generate
37 @go generate ./...
38
39 .PHONY: build
40 build: ## Build example command lines.
41 ./_example/build.sh
42
43 .PHONY: help
44 help: ## Show help text
45 @echo "Commands:"
46 @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-10s\033[0m %s\n", $$1, $$2}'