Makefile 1.1 KB

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