golang-pro
Write, edit, update, or review Go code to a consistent professional standard: gofumpt-formatted, go vet clean, golangci-lint clean under a curated config. Use whenever creating, editing, updating, or linting .go files.
- License 许可
- MIT
- 最近更新
- 2026-11-11
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- golang-pro
- description
- Write, edit, update, or review Go code to a consistent professional standard: gofumpt-formatted, go vet clean, golangci-lint clean under a curated config. Use whenever creating, editing, updating, or linting .go files.
- compatibility
- Requires the Go toolchain on PATH (go >= 1.26); golangci-lint for the full standard
02 资源文件 12
- 其他agents/openai.toml1.1 KB
- 资产文件assets/.editorconfig3.1 KB
- 资产文件assets/.golangci-script.yml1.8 KB
- 资产文件assets/.golangci.yml3.2 KB
- 参考文档README.md3.2 KB
- 参考文档references/comments.md1.6 KB
- 参考文档references/design.md4.6 KB
- 参考文档references/naming.md3.2 KB
- 脚本scripts/check3.2 KB
- 脚本scripts/fmt1.6 KB
- 脚本scripts/init-config1.6 KB
- 脚本scripts/new-script3.2 KB
03 SKILL.md 正文
Golang Pro
Purpose
Produce Go that is correct, readable, and idiomatic: gofumpt-formatted,
go vet clean, golangci-lint clean under assets/.golangci.yml, following
Effective Go and the Google Go Style Guide. Guiding philosophy is "least
mechanism": the core language first, then the standard library, then a
dependency — and only when the simpler option genuinely cannot do the job.
Workflow
- Classify the target. Module or one-off program?
- Module (a
go.mod): install the shared config withscripts/init-config(never overwrites without--force). Full standard: curated golangci-lint, doc comments on all exported identifiers, table-driven tests. Keep thegodirective current; it governs whatmodernizemay suggest. - One-off program (single
package main, run withgo run): scaffold withscripts/new-script, which also writes a script-profile.golangci.ymlnext to it (same curated base;err113/ireturn/unparam/duplrelaxed, govet on its default analyzers) unless a golangci-lint config is already discoverable in that directory or its parents, or--no-configis given. Plainscripts/checkthen enforces the standard with no flags;--scriptremains for ad-hoc checks that skip golangci-lint entirely.
- Module (a
- Write to the standard. Headlines: gofumpt formatting (tabs; stdlib
imports in their own group at the top); doc comments on all exported
identifiers — full sentences starting with the identifier's name;
errors are values: wrap with
%wonly to expose an error for programmatic inspection, check witherrors.Is/errors.As, sentinel errors as package-levelErrXxxvars, neverreturn nil, nil; small interfaces (1–3 methods) declared at the consumer side, accept interfaces and return concrete types; noGetprefix on getters; MixedCaps with uniform initialisms (ID,URL,db,url); short consistent receivers (r,s), neverthis/self; guard clauses, noelseafterreturn;ctx context.Contextfirst parameter, never stored in structs; no naked shared state between goroutines — share memory by communicating. Followreferences/naming.md,references/design.md, andreferences/comments.md. - Lint. Run
scripts/check(gofumpt gate,go vet,golangci-lint run). Fix every finding. A//nolintis allowed only for a specific linter with a real reason (//nolint:thelper // test helper, no *testing.T); blanket//nolintis banned (nolintlintenforces this). - Format. Run
scripts/fmt(gofumpt -w, plusgoimports -wwhen available). Never hand-format around its output. - Vet.
go vetruns insidescripts/check; the compiler is the typechecker —go build ./...must pass before anything else matters. - Test.
go test ./...; table-driven tests, black-box_testpackages for new packages,t.Helper()as the first line of helpers. (go testalready runs a subset of vet checks — a failing vet there is still a failure.) - Report per the Output Contract.
Review mode
When asked to review (not change) code: run scripts/check on it, walk the
Output Contract as a checklist against the untouched files, and report
findings ordered by severity (correctness first, then API design, then
style), each with a file:line reference and the concrete fix. Do not edit
the files. If the code is vendored third-party or generated, say so and
don't apply the standard to it.
Output Contract
- Path(s) of every file created or changed.
- gofumpt: clean (or formatted, listing what changed).
- go vet: clean.
- golangci-lint: clean, or each remaining finding listed with its
justification and a linter-specific
//nolint. - Tests:
go test ./...results. - Short changelog: what changed and what it was tested with.
Tooling
gofumpt -l— the format gate; a strict superset of gofmt.go install mvdan.cc/gofumpt@latest(requires go >= 1.26).go vet— the toolchain's suspicion heuristics; instant and dependency-free, soscripts/checkalways runs it.golangci-lint run— the full curated suite (assets/.golangci.yml). Pin a release for CI; never install at HEAD there.golangci-lint fmt— runs the configured formatters (v2).gopls— editor integration:"gofumpt": true,"local"set to the module path for import grouping,"staticcheck": true.go test ./...— tests plus a subset of vet checks.assets/.golangci.yml— the curated strict config for modules.assets/.golangci-script.yml— the relaxed configscripts/new-scriptwrites next to one-off programs.assets/.editorconfig— editor whitespace/indent defaults (Go: tabs), installed byscripts/init-config.
Operating Rules
- No file is done until
scripts/checkis clean or every remaining finding carries a justified, linter-specific//nolint. - Always run
scripts/fmtbeforescripts/check; never commit hand formatting that contradicts gofumpt. - When editing, match the file's existing style; do a full restyle only on request.
- Least mechanism: stdlib before a new dependency. A new dependency needs a reason stated in the changelog.
- Never silently discard errors — check them, wrap them with intent, or
justify the
//nolint:errcheck. - One complexity family only (
cyclop, max 15): never stackfunlen,gocognit, ornestifon top. - gofumpt owns whitespace: never add
wsl,nlreturn, orlllto the config. - Keep this file's core stable; lengthy guidance belongs in
references/.
Sources
- Effective Go — https://go.dev/doc/effective_go
- Google Go Style Guide — https://google.github.io/styleguide/go/
- gofumpt — https://github.com/mvdan/gofumpt
- golangci-lint — https://github.com/golangci/golangci-lint
- Go wiki: CodeTools — https://go.dev/wiki/CodeTools
- gopls settings — https://pkg.go.dev/golang.org/x/tools/gopls
04 同仓库更多 Skills
shell-script-expert
Use when the user asks "review this script", "write a bash script", "fix my shell script", "make this script safer", "why does this script fail", "convert this to a script", or working with .sh/.bash files, sh/bash syntax, shellcheck, cronjobs, and bash one-liners.
prose-synthesize
Turn unstructured notes into a structured, actionable plan. Use when given brain dumps, stream-of-consciousness, or scattered thoughts needing order.
prose-distill
Condense verbose text to its essence. Use when asked to condense, tighten, shorten, reduce verbosity, or omit needless words while preserving substance.
mindcraft
暂无简介
learn
Tutor for intellectual understanding: teach how or why something works rather than complete a task or provide an evaluative verdict. Trigger for explicit learning requests (teach, explain, ELI5, walkthroughs, quizzes, flashcards, definitions); terse concept prompts; confusion signals; prerequisite or sequencing questions; and conceptual questions about mechanisms, causes, or dynamics. Do not trigger for task completion (coding, writing, calculation, or translation), factual or news lookup, personal troubleshooting, resource recommendations, or opinion and interpretive verdicts.
deployment-readiness
Use to check deployment readiness of a host.