plugins/languages/golang/skills/tooling/SKILL.md
Go 工具链规范——gofmt/goimports 格式化、go mod 依赖管理 + tool 指令(Go 1.24+)、toolchain 指令、golangci-lint v2 + govulncheck 安全扫描、delve 调试、go test -fuzz 模糊测试、pprof + trace 性能分析、go fix 现代化(Go 1.26 重写)、交叉编译。装环境、跑命令、配置 Makefile/CI、做基线检查时触发。
npx skillsauth add lazygophers/ccplugin golang-toolingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
gofmt -w .
goimports -w .
编辑器配置:
{
"go.formatTool": "goimports",
"go.lintTool": "golangci-lint",
"go.lintOnSave": "file",
"go.formatOnSave": true
}
go mod init github.com/username/project
go mod tidy
go get github.com/lazygophers/utils@latest
go list -m all
go mod graph
go.mod 显式声明:
go 1.26.0
toolchain go1.26.0
升级:
go get [email protected]
go get [email protected]
// go.mod
tool golang.org/x/tools/cmd/stringer
tool github.com/golang/mock/mockgen
go tool stringer -type=Status
不再需要 tools.go + //go:build tools 黑魔法。
latest 提交govulncheck ./...go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...
govulncheck -mode=binary ./bin/app
详见 golang-lint。
curl -sSfL https://golangci-lint.run/install.sh | sh -s -- -b ./bin v2.12.2
./bin/golangci-lint run ./...
go install github.com/go-delve/delve/cmd/dlv@latest
dlv debug ./cmd/main.go
dlv test ./internal/impl/
dlv attach <pid>
(dlv) b main.main
(dlv) c
(dlv) goroutines
(dlv) bt
(dlv) print user
# 完整测试 + race
go test -v -race -cover ./...
# 模糊测试
go test -fuzz=FuzzParseInput -fuzztime=30s ./parser/
# 基准
go test -bench=. -benchmem -count=5 ./...
benchstat old.txt new.txt
# 覆盖率
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out
go tool cover -func=coverage.out | grep total
# CPU/内存
go test -cpuprofile=cpu.prof -memprofile=mem.prof ./...
go tool pprof -http=:8080 cpu.prof
# 线上 endpoint
go tool pprof http://localhost:6060/debug/pprof/heap
go tool pprof http://localhost:6060/debug/pprof/goroutine
# trace
go test -trace=trace.out ./...
go tool trace trace.out
# Goroutine 泄漏剖析(1.26 实验,1.27 拟默认)
GOEXPERIMENT=goroutineleakprofile go build .
# 访问 /debug/pprof/goroutineleak
go fix ./...
Go 1.26 重写后基于 go vet 分析框架,提供数十个 modernizer 自动应用现代语法:
for i := 0; i < n; i++ → for i := range ninterface{} → anyerrors.New(fmt.Sprintf(...)) → fmt.Errorf(...)//go:fix inline 做 API 迁移强烈建议升级 1.26 后跑一次 go fix ./...。
//go:generate protoc --go_out=. ./proto.proto
//go:generate stringer -type=Status
go generate ./...
go build ./...
go build -o bin/app ./cmd/main.go
# 交叉编译
GOOS=linux GOARCH=amd64 go build -o bin/app-linux ./cmd/main.go
GOOS=darwin GOARCH=arm64 go build -o bin/app-mac-arm64 ./cmd/main.go
# 体积优化
go build -ldflags="-s -w" -trimpath -o bin/app ./cmd/main.go
.PHONY: check
check:
gofmt -w .
goimports -w .
go vet ./...
./bin/golangci-lint run ./...
govulncheck ./...
go test -race -cover ./...
| AI 借口 | 实际应验证 | | --- | --- | | "gofmt 够了" | 跑 goimports? | | "go vet 严格" | 跑 golangci-lint v2? | | "依赖没漏洞" | 跑 govulncheck? | | "print 调试" | 用 delve 断点? | | "手管 Go 版本" | go.mod toolchain 指令? | | "tools.go 还在" | 迁到 1.24 tool 指令? | | "没跑 go fix" | 1.26 跑一次现代化? |
gofmt + goimports 已跑go vet ./... 无告警golangci-lint run 通过(v2)govulncheck ./... 无 HIGHgo mod tidy 已跑go.mod 有 toolchain 指令tool 指令(非 tools.go)go test -race -cover ./... 通过go fix ./...tools
--- name: trellisx-workspace description: 维护 `.trellis/task.md` 任务看板 —— trellis 缺的跨任务总览。**一个表格, 一行一个任务**, 列为 id/名称/描述/状态/阶段/进度/worktree (状态/阶段中文显示)。在 task create/start/阶段切换/archive 后**及时更新**对应行; 并**自动清理超 7 天的已完成行**防膨胀。保持看板与 task.json 实时一致。 when_to_use: 维护 / 创建 / 更新 `.trellis/task.md` 任务看板时; task 生命周期任一节点 (create/start/阶段推进/archive) 之后同步看板时; 用户问"当前有哪些任务 / 任务进度 / 任务看板"时。被 trellisx-flow 与 trellisx-apply 注入的流程引用。 user-invocable: true argument-hint: [show|update|sync|cleanup ...] [task id] arguments:
testing
强制以 Trellis task 闭环处理用户指定的请求 (自判新建/并入 → plan→exec→check→finish 全程不跳步)。**仅用户显式主动调用** (/trellisx-flow 或明确要求"强制走 task 处理这个"); **禁止自动 / 被动 / 推断式调用** —— 不要因为某个请求"看起来该建 task"就自动触发本 skill, 那是 apply 注入的 no_task 倾向的职责。
testing
把 强推task + subtask拆分 + worktree隔离 + 闭环收尾 四维度增量注入当前项目 .trellis/ (workflow.md 的 no_task/planning/in_progress 块 + spec 背书文档 + trellis 生命周期 hook worktree 自动化)。强推 task 与闭环为纯 prompt 软约束 (非平台 hook 硬拦截)。**纯增量追加, 绝不替换 trellis 原生文本** (no_task 分类+征同意/check/finish/前缀全保留)。幂等 (marker 包裹)。
development
Claude Code 会话历史整理 — 扫 ~/.claude/projects/**/*.jsonl 全部 session transcripts, 提取学习增量 (用户校正/决策/踩坑/L0 规则) → 全局记忆库 ~/.cortex/.wiki/memory/. 默认 --apply 落盘 (--dry-run opt-in 仅出 JSON plan 预览). 与 cortex-extract (L4-inbox 内部) 互补.