.golangci.yml:
- 启用 linter: errcheck, gosec, govet, staticcheck, ineffassign, unused,
revive, contextcheck, errorlint, errname, misspell
- 启用 formatter: gofumpt + goimports
Makefile:
- fmt/fmt-check: gofumpt + goimports 格式检查
- lint/lint-strict: golangci-lint 报告/阻断模式
- test: go test -race
- ci: 完整 CI 流程 (fmt-check + lint)
docs/code-style.md:
- 新增 AI 执行协议 + 代码格式化/自动化检查/MUST规则
- 集成 golangci-lint 检查项与规范对照
42 lines
973 B
YAML
42 lines
973 B
YAML
version: "2"
|
||
|
||
linters:
|
||
default: none
|
||
|
||
enable:
|
||
- errcheck # 未处理的 error 返回值
|
||
- gosec # 安全漏洞模式
|
||
- govet # go vet 标准检查(含 copylocks)
|
||
- staticcheck # 大量静态分析规则
|
||
- ineffassign # 无效赋值
|
||
- unused # 未使用的变量/常量/函数/类型
|
||
- revive # 代码风格(doc 注释等)
|
||
- contextcheck # context.Background() 误用检测
|
||
- errorlint # errors.Is / errors.As 使用检测
|
||
- errname # Sentinel error 必须以 Err 为前缀
|
||
- misspell # 拼写错误
|
||
|
||
settings:
|
||
gosec:
|
||
excludes: []
|
||
|
||
staticcheck:
|
||
checks: ["all"]
|
||
|
||
revive:
|
||
severity: warning
|
||
|
||
exclusions:
|
||
paths:
|
||
- third_party
|
||
- ".*_test\\.go$"
|
||
|
||
formatters:
|
||
enable:
|
||
- gofumpt # 比 gofmt 更严格的格式化
|
||
- goimports # import 自动分组 + 增删
|
||
|
||
run:
|
||
timeout: 5m
|
||
tests: true
|