go-standards
Use when writing, reviewing, testing, formatting, or configuring any Go code in a repo that follows touchstone (gofumpt, golangci-lint v2, go test -race, slog, distroless). Invoke before adding deps, editing tests, or designing packages/APIs.
- License 许可
- MIT
- 最近更新
- 2026-08-26
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- go-standards
- license
- MIT
- metadata
- { "author": "touchstone", "version": "0.2.0" }
- description
- Use when writing, reviewing, testing, formatting, or configuring any Go code in a repo that follows touchstone (gofumpt, golangci-lint v2, go test -race, slog, distroless). Invoke before adding deps, editing tests, or designing packages/APIs.
03 SKILL.md 正文
Go Standards
Full standard: standards/languages/golang.md in the touchstone repo. This skill inlines the
load-bearing rules so it stays useful even when installed standalone in ~/.claude/skills/:
Always
- Pin Go via
go+toolchaindirectives;GOTOOLCHAIN=localin CI. Commitgo.sum; build-mod=readonly. - Format with gofumpt + goimports; lint with golangci-lint v2 (standard set + gosec/bodyclose/errorlint).
- Table-driven tests +
go test -racealways; stdlibtesting+go-cmp, not testify. Coverage floor. govulncheck ./...in CI;go mod tidymust produce no diff.
Don't get burned
- Wrap errors with
%w; match viaerrors.Is/As. Nopanicin libraries; never ignore errors with_. context.Contextis the first arg, never stored in a struct; alwaysdefer cancel().- Every goroutine needs an owned exit path; use
errgroupfor bounded parallel work. - Flat layout +
internal/— rejectgolang-standards/project-layout/pkg/. Accept interfaces, return structs. - HTTP servers: set
http.Servertimeouts (the zero-value server is a Slowloris DoS); stdlibhttp.ServeMux(1.22+); graceful shutdown viasignal.NotifyContext+srv.Shutdown(ctx). JSON: tags mandatory,DisallowUnknownFieldsat boundaries.database/sql: bound the pool (zero-value is unbounded). - Logging via stdlib
log/slog(JSON). Ship static (CGO_ENABLED=0) on distroless nonroot.
Done
gofumpt -l . empty · golangci-lint run clean · go test -race ./... green · govulncheck clean · go mod tidy no diff.
04 同仓库更多 Skills
ok-standards
Use when writing shell, per standards/languages/shell.md.
demo-standards
Use when editing demo code in a touchstone fixture repo, a deliberately ordinary description that is long enough to clear the forty character minimum.
demo-standards
Use when editing demo code in a touchstone fixture repo, a deliberately ordinary description that is long enough to clear the forty character minimum.
demo-standards
Use when editing demo code in a touchstone fixture repo, a deliberately ordinary description that is long enough to clear the forty character minimum.
demo-standards
Use when editing demo code in a touchstone fixture repo, a deliberately ordinary description that is long enough to clear the forty character minimum.
demo-standards
Use when editing demo code in a touchstone fixture repo, a deliberately ordinary description that is long enough to clear the forty character minimum.