-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathMakefile
More file actions
49 lines (37 loc) · 802 Bytes
/
Makefile
File metadata and controls
49 lines (37 loc) · 802 Bytes
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
.PHONY: build run clean fmt vet tidy test lint docker
APP_NAME := gonio
BUILD_DIR := bin
MAIN_PATH := cmd/server/main.go
# 构建
build:
go build -o $(BUILD_DIR)/$(APP_NAME) $(MAIN_PATH)
# 运行
run:
go run $(MAIN_PATH)
# 清理
clean:
rm -rf $(BUILD_DIR)/
# 代码格式化
fmt:
go fmt ./...
# 代码检查
vet:
go vet ./...
# 下载依赖
tidy:
go mod tidy
# 运行测试
test:
go test -v -race -count=1 ./...
# 运行测试并生成覆盖率报告
test-cover:
go test -race -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
# 静态检查(需要安装 golangci-lint)
lint:
golangci-lint run ./...
# Docker 构建
docker:
docker build -t $(APP_NAME):latest .
# 一键检查:格式化 + 静态分析 + 测试
check: fmt vet lint test