Google style go
Minimalist Cross-Agent Skills Manager
npx -y skills add sanjeevafk/agent-skills --skill google-style-goAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Apply Google's official Go style guide when writing, reviewing, or formatting Go code. Use this skill whenever the user asks to review Go code for style, asks about Go naming conventions, error handling patterns, package organisation, comment format, goroutine safety, or whether code follows Google/Uber/idiomatic Go conventions. Also triggers on: "is this idiomatic Go?", "clean up this Go code", "how should I name this in Go?", "how do I handle errors in Go?", "should I use goroutines here?", "what's the Google way for Go package structure?", or any request involving gofmt, golangci-lint, or go vet in a style context. Google's Go guide covers three dimensions: style rules (guide.md), best practices (best-practices.md), and decision rationale (decisions.md) — this skill knows when to consult each.
SKILL.md
6.5 KB, ~1.4k tokens by cl100k_base, as published. Nobody here has run it
Google Go Style Guide
Google maintains three complementary Go guides:
- Style guide (
guide.md) — the authoritative rules - Best practices (
best_practices.md) — patterns and idioms for common situations - Decisions (
decisions.md) — rationale behind choices, useful when defending or questioning a rule
Key themes across all three: names are short and clear, errors are explicit and
never ignored, goroutines are always bounded, and formatting is handled entirely
by gofmt (never argue about it).
Key Rules at a Glance
Naming
- Packages: short, lowercase, no underscores, singular (
usernotusers). Avoid generic names likeutil,common,misc. - Exported names:
PascalCase, descriptive but not redundant with the package name (user.Client, notuser.UserClient). - Unexported names:
camelCase. - Acronyms: keep full case —
HTTPServer,userID,parseURL. - Interfaces: name by the behaviour they express, often
-ersuffix (Reader,Stringer). Single-method interfaces are encouraged. - Error vars: prefix with
Errfor sentinel errors (ErrNotFound), suffix withErrorfor types (NotFoundError). - Receivers: short, 1-2 letter abbreviation of the type. Consistent across all methods (
cforClient, not mixingcandclient).
Error handling
- Never ignore errors — check every returned error.
- Wrap errors with context using
fmt.Errorf("doing X: %w", err). - Use
errors.Is()/errors.As()to inspect wrapped errors — never string matching. - Return early on error (the "happy path" stays un-indented).
- Sentinel errors (
var ErrNotFound = errors.New(...)) only for errors callers need to match; otherwise just return descriptive wrapped errors.
Goroutines
- Every goroutine must have a clear owner responsible for its lifetime.
- Goroutines must have a way to stop — pass a
context.Contextor use a done channel. - Document goroutine safety in comments: state whether a type is safe for concurrent use.
- Prefer
sync.WaitGroup+ bounded worker pools over unbounded goroutine spawning.
Comments
- Every exported identifier needs a doc comment starting with the identifier's name:
// Client manages connections to the backend. type Client struct { ... } // Do executes the given request and returns the response. func (c *Client) Do(req *Request) (*Response, error) { ... } - Package doc goes in
doc.goor at the top of the main file:// Package user provides... - Use
//nolintwith a reason, never silently.
Formatting
- Run
gofmt— no discussion. All Google Go code isgofmt-formatted. - Line length: no hard limit, but keep lines readable (~100 chars is a soft target).
- Imports: stdlib → third-party → internal, separated by blank lines (
goimportshandles this).
Context
context.Contextis the first parameter of any function that does I/O, calls RPCs, or may be cancelled.- Name the parameter
ctx. - Never store
Contextin a struct field — pass it through function calls.
Which reference file to load
| Task | Load |
|---|---|
| "Is this naming correct?" | references/guide.md |
| "How should I structure this package?" | references/best_practices.md |
| "Why does Go do X this way?" | references/decisions.md |
| Comprehensive code review | all three |
| Quick lookup of a specific rule | references/index.md first |
Mode: Reviewing Go Code
When asked to review Go code for Google style compliance:
- Naming — correct casing? Package name concise and non-generic? Receiver names consistent?
- Error handling — every error checked? Errors wrapped with
%w?errors.Is()/errors.As()for inspection? - Comments — all exported identifiers have doc comments? Comments start with the name?
- Context —
ctx context.Contextas first param on I/O functions? Not stored in structs? - Goroutines — do they have clear owners and a stop mechanism? Is there a risk of goroutine leak?
- Imports — three groups,
goimportsordered? Any dot imports (import . "pkg")? - Formatting — assume
gofmtis run; flag only structural issues. - Interfaces — defined at the point of use (not in the package that implements them)?
For each issue:
- Cite the relevant file (
guide.md §X,best_practices.md §Y) - Show the problematic snippet and the corrected version with brief rationale
Mode: Writing New Go Code
When writing new Go following Google style:
- Package name: short, lowercase, singular, descriptive.
context.Contextas first param on any function doing I/O.- Return errors explicitly; use
fmt.Errorf("context: %w", err)to wrap. - All exported identifiers get doc comments — name first.
- Interfaces defined where they're consumed, not where they're implemented.
- Goroutines: always pass a
ctxor done channel; document who owns cleanup. - Use
errors.Is()/errors.As()to match specific error types. - Short, early returns on error — keep the happy path at the left margin.
- Prefer table-driven tests (
[]struct{ name, input, want }). - Run
gofmtandgo vetbefore considering code done.
When to Load a Reference File
All three reference files are large (400–3,800 lines each). Load only what you need:
references/index.md— 171-line overview and links to topics, good starting pointreferences/guide.md— 440 lines, the core rulesreferences/best_practices.md— 3,828 lines, patterns for specific situationsreferences/decisions.md— 3,604 lines, rationale and trade-offs
Also see: google-style-common for cross-language principles on naming and comments.