-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
64 lines (52 loc) · 1.51 KB
/
Copy pathMakefile
File metadata and controls
64 lines (52 loc) · 1.51 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
.PHONY: fe build build-all clean run statik swagger help
BINARY_NAME=pigo
BUILD_DIR=bin
# Build frontend
fe:
cd fe && npm install && npm run build
# Build backend
build:
go build -o $(BUILD_DIR)/$(BINARY_NAME) ./cmd/server/
# Generate statik embedded files
statik:
statik -src=fe/dist -dest=.
# Generate swagger docs
swagger:
swag init -g cmd/server/main.go -o docs
# Build all: frontend -> statik -> backend
build-all: fe statik swagger build
# Run the server locally
run:
go run ./cmd/server/
# Clean build artifacts
clean:
rm -rf $(BUILD_DIR)
rm -rf fe/dist
rm -rf statik/statik.go
# Run tests
test:
go test -v -race -coverprofile=coverage.out ./...
# Format code
fmt:
gofmt -s -w .
# Lint
lint:
go vet ./...
# Show help
help:
@echo ""
@echo "Usage: make <target>"
@echo ""
@echo "Targets:"
@echo " fe 构建前端(npm install + npm run build)"
@echo " build 构建后端二进制(输出 bin/pigo)"
@echo " build-all 完整构建:前端 -> statik 嵌入 -> swagger -> 后端"
@echo " statik 将 fe/dist 静态资源嵌入到 statik/statik.go"
@echo " swagger 生成 Swagger API 文档"
@echo " run 本地运行服务(go run)"
@echo " test 运行单元测试(含竞态检测和覆盖率)"
@echo " fmt 格式化 Go 代码(gofmt)"
@echo " lint 代码静态检查(go vet)"
@echo " clean 清理构建产物(bin/、fe/dist/、statik/statik.go)"
@echo " help 显示此帮助信息"
@echo ""