-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile
52 lines (40 loc) · 1.19 KB
/
justfile
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
projectname := "ghproxy-go"
# 列出所有可用的命令
default:
@just --list
# 构建 Golang 二进制文件
build:
go build -ldflags "-X main.version=$(git describe --abbrev=0 --tags)" -o {{projectname}}
# 安装 Golang 二进制文件
install:
go install -ldflags "-X main.version=$(git describe --abbrev=0 --tags)"
# 运行应用程序
run:
go run -ldflags "-X main.version=$(git describe --abbrev=0 --tags)" main.go
# 安装构建依赖
bootstrap:
go generate -tags tools tools/tools.go
# 运行测试并显示覆盖率
test: clean
go test --cover -parallel=1 -v -coverprofile=coverage.out ./...
go tool cover -func=coverage.out | sort -rnk3
# 清理环境
clean:
rm -rf coverage.out dist {{projectname}} {{projectname}}.exe
# 显示测试覆盖率
cover:
go test -v -race $(go list ./... | grep -v /vendor/) -v -coverprofile=coverage.out
go tool cover -func=coverage.out
# 格式化 Go 文件
fmt:
gofumpt -w .
gci write .
# 运行 linter
lint:
golangci-lint run -c .golang-ci.yml
# 测试发布
release-test:
goreleaser release --snapshot --clean
# 运行 pre-commit 钩子(已注释)
# pre-commit:
# pre-commit run --all-files