-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
109 lines (91 loc) · 2.66 KB
/
Copy pathMakefile
File metadata and controls
109 lines (91 loc) · 2.66 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# SaokaCache Makefile
.PHONY: all build test clean lint fmt vet bench cover proto help
# 默认目标
all: fmt vet test build
# 构建项目
build:
@echo "构建项目..."
go build ./...
# 运行所有测试
test:
@echo "运行测试..."
go test ./...
# 运行测试并显示详细输出
test-verbose:
@echo "运行详细测试..."
go test -v ./...
# 运行特定包的测试
test-store:
@echo "运行 store 包测试..."
go test ./store/...
# 运行性能测试
bench:
@echo "运行性能测试..."
go test -bench=. ./store/...
# 运行竞态检测
test-race:
@echo "运行竞态检测..."
go test -race ./...
# 生成测试覆盖率
cover:
@echo "生成测试覆盖率..."
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
@echo "覆盖率报告已生成: coverage.html"
# 格式化代码
fmt:
@echo "格式化代码..."
go fmt ./...
# 静态分析
vet:
@echo "运行静态分析..."
go vet ./...
# 代码检查(需要安装 golangci-lint)
lint:
@echo "运行代码检查..."
golangci-lint run
# 生成 protobuf 代码
proto:
@echo "生成 protobuf 代码..."
protoc --go_out=. --go-grpc_out=. pb/kama.proto
# 清理构建产物
clean:
@echo "清理构建产物..."
go clean
rm -f coverage.out coverage.html
# 更新依赖
deps:
@echo "更新依赖..."
go mod tidy
go mod download
# 运行示例
example:
@echo "运行示例(3 节点)..."
@echo "请在不同终端运行以下命令:"
@echo "go run example/test.go -port 8001 -node node1"
@echo "go run example/test.go -port 8002 -node node2"
@echo "go run example/test.go -port 8003 -node node3"
# 检查代码质量
check: fmt vet lint test
@echo "代码质量检查完成!"
# 显示帮助
help:
@echo "SaokaCache 开发命令:"
@echo ""
@echo " make all - 运行格式化、分析、测试和构建"
@echo " make build - 构建项目"
@echo " make test - 运行所有测试"
@echo " make test-verbose - 运行详细测试"
@echo " make test-store - 运行 store 包测试"
@echo " make bench - 运行性能测试"
@echo " make test-race - 运行竞态检测"
@echo " make cover - 生成测试覆盖率报告"
@echo " make fmt - 格式化代码"
@echo " make vet - 运行静态分析"
@echo " make lint - 运行代码检查(需要 golangci-lint)"
@echo " make proto - 生成 protobuf 代码"
@echo " make clean - 清理构建产物"
@echo " make deps - 更新依赖"
@echo " make example - 显示运行示例的命令"
@echo " make check - 运行完整的代码质量检查"
@echo " make help - 显示此帮助信息"