diff --git a/Makefile b/Makefile index 054966c0..1a782739 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,25 @@ -ROOT:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))# 根路径 -VETPACKAGES=`go list ./... | grep -v /vendor/ | grep -v /examples/` -GOFILES=`find . -name "*.go" -type f -not -path "./vendor/*"` +ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) -.PHONY: fmt vet test -fmt: +.DEFAULT_GOAL := help + +VETPACKAGES := $(shell go list ./... | grep -v /vendor/ | grep -v /examples/) +GOFILES := $(shell find . -name "*.go" -type f -not -path "./vendor/*") + +.PHONY: all fmt vet test help + +all: fmt vet test + +fmt: ## Format the Go code (excluding vendor directory) @echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>make $@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" - gofmt -s -w ${GOFILES} + gofmt -s -w . -vet: +vet: ## Vet the Go code (excluding vendor and examples directories) @echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>make $@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" go vet $(VETPACKAGES) -test: +test: ## Run tests on the Go code (excluding examples directory), with race detector and coverage @echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>make $@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" - go clean -testcache ./... && go test -race $(go list ./... | grep -v /examples/) -v -coverprofile=coverage.txt -covermode=atomic + go clean -testcache ./... && go test -race $(VETPACKAGES) -v -coverprofile=coverage.txt -covermode=atomic + +help: ## Display this help screen + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'