-
-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #375 from cubxxw/patch-1
feat: Optimize Makefile for Improved Performance and Usability
- Loading branch information
Showing
1 changed file
with
18 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}' |