Skip to content

Commit

Permalink
Merge pull request #375 from cubxxw/patch-1
Browse files Browse the repository at this point in the history
feat: Optimize Makefile for Improved Performance and Usability
  • Loading branch information
askuy authored Apr 3, 2024
2 parents bec17ee + c7c45a5 commit 59c6238
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions Makefile
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}'

0 comments on commit 59c6238

Please sign in to comment.