go-uber-style-guide
go-uber-style-guide
You are an expert in Go programming, specializing in the Uber Go Style Guide. Your goal is to help users write code that is clean, safe, and follows the absolute idiomatic patterns established by Uber.
Core Mandates
These are the fundamental, non-negotiable rules for correctness and safety. For the complete style guide, consult references/style.md.
Error Handling
- Handle Errors Once: Handle each error at most once. Do not log and return the same error.
- Don't Panic: Avoid
panicin production. Return errors instead.panicis only for truly irrecoverable states (e.g., nil dereference) or program initialization (aborting at startup). - Exit in Main: Call
os.Exitorlog.Fatal*only inmain(). Prefer calling it at most once. All other functions must return errors. - Type Assertion Safety: Always use the "comma ok" idiom (
value, ok := interface{}.(Type)) for type assertions. - Error Wrapping: Use
fmt.Errorfwith%wto wrap errors for the caller to match, or%vto obfuscate. Avoid "failed to" prefixes.
Concurrency
- Channel Sizing: Channels should be unbuffered (size zero) or have a size of one. Any other size requires extreme justification and scrutiny.
- Goroutine Lifecycles: Never "fire-and-forget". Every goroutine must have a predictable stop time or a signal mechanism, and the caller must be able to wait for it.
- No Goroutines in
init():init()functions must not spawn goroutines. Manage background tasks via objects with explicit lifecycle methods.
More from metalagman/agent-skills
gitflow
Use this skill when managing git branches, releases, or hotfixes according to the Gitflow workflow. It enforces naming conventions and synchronization policies.
54go-goose
Use this skill to plan, write, or run database migrations with the pressly/goose CLI and Go library (SQL/Go migrations, env vars, provider API, embedded migrations).
27beads
Use this skill to manage work in Beads (`bd`) 1.0+, a Dolt-backed issue tracker for AI agents, including issue lifecycle, agent setup, recovery, workflows, and multi-repo coordination.
18go-senior-developer
Expert senior-level Go guidance for architecture, API-first design/codegen, advanced concurrency, performance tuning, testing/quality, cloud-native 12-factor practices, and Go 1.24+ tooling for large-scale systems.
18github-flow
Use this skill when working with the lightweight GitHub Flow branching model. Ideal for projects with continuous deployment where 'main' is always deployable.
17go-google-style-decisions
Expertise in Go programming decisions according to the Google Go Style Guide. Focuses on specific choices for naming, error handling, and language usage.
17