go-style
Skill2 starsChanged 47 days agoMITView on GitHub
How to write Go the way the Go community does — naming, errors, comments and doc comments, readability (paragraphs, function and file shape, parameters), packages and project layout, interfaces, tests, tooling and linters, concurrency — every rule taken from recognized sources (the Go team's Effective Go, Code Review Comments and go.dev docs, the standard library, the Google and Uber Go style guides, Dave Cheney's Practical Go) with its citation. Use this skill whenever you write, review, refactor or explain Go code, in any project — a new function, a test, a package layout, an error message, a doc comment, a linter configuration — and whenever someone asks what is idiomatic in Go, what "the convention" is, or how Go compares with what they know from TypeScript or other languages, even if they don't say "style".
1 other project uses a version of this.
Adopted by
Most recently taken up by
- els0r/skillstheir own version, first seen Oct 13, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- els0r/skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository7 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- llms.txtllms.txt
- open-prSkill
- orchestrateSkill
- wtm-docsSkill
- wtm-sandboxSkill
- wtm-siteSkill
The file
We split this skill into the rules it gives an agent
12 rules. About 0 are common, 5 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Every rule here comes from a source the Go community recognizes, cited in the reference files.
- Very specific: line 21
Call the error err and reuse it.
- Very specific: line 22
Don't repeat the package in what it exports (bufio.Reader, widget.New).
- Distinctive: line 26
Check every error and handle it once: return it or log it, never both.
- Very specific: line 28
Add context naming the operation ("open config: %w").
- Very specific: line 33
Every exported name has a doc comment: a full sentence that starts with the name (// Run carries out …), "reports whether" for booleans, …
- Distinctive: line 38
Use blank lines to break a function into paragraphs, the way paragraphs break a document (Cheney).
- Very specific: line 41
Prefer a nil slice to []T{}, useful zero values, field names in composite literals of other packages' types.
- Distinctive: line 42
No hard line-length limit.
- Distinctive: line 50
Keep interfaces small; accept interfaces, return concrete types (with Google's listed exceptions).
- Very specific: line 57
Prefer real implementations, then fakes.
- Very specific: line 65
Every goroutine has a known exit and someone waiting for it (sync.WaitGroup, errgroup).
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
go-style — Go as the community writes it
Every rule here comes from a source the Go community recognizes, cited in the reference files. When sources disagree, follow them in this order — and each reference's last section says which side we took and why:
- The Go team: Effective Go, Go Code Review Comments (CRC), Go Doc Comments, module layout, the Go blog, and the standard library's own code.
- The Google Go Style Guide (guide, decisions, best practices).
- The Uber Go Style Guide.
- Recognized authors: Dave Cheney (Practical Go), Rob Pike (Go Proverbs, "Errors are values"), Ben Johnson, Mitchell Hashimoto.
A project's established convention wins over a general rule when the two conflict (consistency inside a codebase is itself a rule of every guide); say so when you follow the project against the community, and propose aligning it when the project rule has no reason left.
The rules that matter most
Naming — references/naming.md
- A name's length follows the distance between its declaration and its uses: short for a local in a small scope, descriptive for a package-level name.
- Call the error
errand reuse it; give distinct short names only when two errors are alive at once (er/ewinio.copyBuffer). Watch:=shadowing inside a block. - Don't repeat the package in what it exports (
bufio.Reader,widget.New); noutil/common/miscpackages; initialisms keep one case (URL,ID); no ALL_CAPS constants. - Receivers are one or two letters, the same in every method, never
this/self; getters areOwner(), notGetOwner().
Errors — references/errors.md
- Check every error and handle it once: return it or log it, never both.
- Handle the error first and return; the happy path stays at the left margin, never in an
else. - Add context naming the operation (
"open config: %w"); error strings are lowercase with no final punctuation. - Wrap with
%wonly when callers should inspect the cause — wrapping makes it part of your API; inspect witherrors.Is/errors.As, never by string. - Errors are opaque by default; export an
ErrXsentinel or anXErrortype only when callers must branch on it. Panic only for programmer errors.
Comments — references/comments.md
- Every exported name has a doc comment: a full sentence that starts with the name (
// Run carries out …), "reports whether" for booleans, the contract not the algorithm. - A comment inside a body says why (or how, for a step the code can't make obvious); a block that needs a comment because it does something separate becomes a function named after it.
- Section separators (
//+ 76 dashes, then a title line, then a blank line) only in a long file whose declarations fall into named groups; otherwise split the file.
Readability — references/readability.md
- Use blank lines to break a function into paragraphs, the way paragraphs break a document (Cheney).
- Return early, reduce nesting, keep variables in the smallest scope.
- Positional parameters are the norm; reach for an options struct when a function takes many inputs or the call site would be unreadable, and break up several parameters of the same type that a caller could swap (a type, or a struct where it reads better). A struct for two parameters is not a Go convention.
- Prefer a nil slice to
[]T{}, useful zero values, field names in composite literals of other packages' types; no mutable globals, noinit()doing work. - No hard line-length limit; a file is focused enough that a maintainer can tell which file holds something — neither thousands of lines nor many tiny files.
Packages — references/packages.md
- A package provides one concept and is named after it; merge packages that are always used together; put supporting code in
internal/;cmd/holds mains; there is nopkg/convention. - Layering prevents import cycles; dependencies are passed through constructors and wired by hand in
main— no DI framework, no package-level state.
Interfaces — references/interfaces.md
- The consumer declares the interface, with only the methods it calls; don't define one before it is used or to mock a producer.
- Keep interfaces small; accept interfaces, return concrete types (with Google's listed exceptions).
- Pointer receivers when in doubt, and don't mix pointer and value receivers on one type.
Tests — references/testing.md
- Failures read
Func(in) = got, want want; compare withcmp.Difflabelled(-want +got); errors witherrors.Is/errors.As. t.Errorto keep going,t.Fatalfor setup or inside a subtest; helpers callt.Helper()and register teardown witht.Cleanup; uset.TempDir,t.Setenv.- Table-driven tests with
t.Run; fixtures intestdata/; golden files behind an-updateflag. - Prefer real implementations, then fakes; the Go team and Google advise against assertion libraries — a project already on testify keeps it consistently (
requirewhere the test cannot go on,assertotherwise).
Tooling — references/tooling.md
gofmt/goimportsare not negotiable;go vet, staticcheck withchecks: ["all"](its defaults leave the naming and doc-comment checks off),go test -raceandgo mod tidyin CI.- golangci-lint with a deliberate set: the standard set + revive
exported(doc comments), errorlint, gocritic (diagnostic), unparam, misspell, nolintlint, thelper, usetesting.
Concurrency — references/concurrency.md
context.Contextis the first parameter, never stored in a struct; always callcancel.- Every goroutine has a known exit and someone waiting for it (
sync.WaitGroup,errgroup); prefer synchronous functions and let the caller add concurrency. - Mutexes use their zero value, are named fields, are never copied; channels are unbuffered or size one unless a reason is written down.
Read next
Open the reference whose subject you are touching before writing or reviewing it; each one is short, lists its rules with their why and their source, and ends with "Where the sources disagree".
| Reference | Read it when |
references/naming.md | naming anything: package, type, function, receiver, variable, error, constant, test |
references/errors.md | creating, returning, wrapping, inspecting or printing an error; deciding to panic |
references/comments.md | writing a doc comment, a package comment, a comment in a body, a section separator, a TODO, a directive |
references/readability.md | shaping a function or a file: paragraphs, nesting, parameters, named results, zero values, globals |
references/packages.md | creating or splitting a package, laying out a module, wiring dependencies, structuring an application |
references/interfaces.md | declaring an interface or a port, choosing receivers, embedding, writing a test double |
references/testing.md | writing or reviewing a test, a helper, a fixture, a golden file |
references/tooling.md | setting up or running formatters, vet, staticcheck, golangci-lint, gopls, govulncheck, deadcode |
references/concurrency.md | contexts, goroutines, channels, mutexes, errgroup |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

