-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
69 lines (51 loc) · 1.26 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
VERSION = `git rev-parse --short HEAD`
BUILDTIME = `date +%FT%T`
%:
@true
## protoc-gen-go: 安装pb文件生成工具
.PHONY: protoc-gen-go
protoc-gen-go:
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
## protoc-gen-go-grpc: 安装grpc pb文件生成工具
.PHONY: protoc-gen-go-grpc
protoc-gen-go-grpc:
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
## tidy: 整理现有的依赖
.PHONY: tidy
tidy:
go mod tidy
## download: go依赖下载
.PHONY: download
download:
go mod download
## test: 单元测试全部测试代码
.PHONY: test
test:
go test ./... -cover
## vet: 静态检测全部go代码
.PHONY: vet
vet:
# go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest
# go vet -vettool=`which shadow` ./...
go vet ./...
## bench: 并发测试
.PHONY: bench
bench:
go test ./... -test.bench . -test.benchmem=true
## test: 单元测试全部测试代码
.PHONY: fmt
fmt:
gofmt -w -l .
## lint: golangci-lint
.PHONY: lint
lint:
golangci-lint cache clean
golangci-lint run
## check: fmt lint vet
.PHONY: check
check: fmt lint vet
## help: Show this help info.
.PHONY: help
help: Makefile
@echo "\nUsage: make <TARGETS> <OPTIONS> ...\n\nTargets:"
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'