Go Coding Practices
Application skill for Go style learning (from the archived awesome-guidelines style capsules). For service layout or framework patterns, follow project conventions and stack capsules in skills/*-foundation.
Core Principle
Go code should be gofmt-clear, error-explicit, and concurrency-obvious, interfaces earned at the consumer, not invented at the producer.
When to Use / NOT
- Writing or reviewing Go packages, CLIs, or services.
- Setting up
gofmt, go vet, staticcheck in CI.
NOT when:
- Non-Go code.
- Generated protobuf/grpc stubs, validate generators, not hand-edits.
Workflow
- Format & names, gofmt, MixedCaps, context-aware locals (
go-style-formatting-naming.md).
- Errors, ordinary failures usually return
error; preserve the project
policy for panic/recover at invariant or framework boundaries. Consult
go-style-errors-flow.md for source-specific options.
- APIs, concrete returns, small consumer interfaces, named external literals (
go-style-interfaces-apis.md).
- Concurrency, make goroutine lifetime, cancellation, and synchronization
explicit. Use context where needed; assess shared mutable state rather than
banning every global (
go-style-concurrency-context.md).
- Verify, use the project's test/vet/lint commands on changed packages;
additional tools are options, not automatic setup work.
Red Flags
- Ordinary recoverable failures unexpectedly escaping as panics
- Ignored
err without comment
- Exported mega-interfaces for "clean architecture"
go func() with no shutdown
- Snake_case or skipping gofmt
- Positional struct literal for imported types
Verification
gofmt -l clean; go vet ./...; project staticcheck/golangci-lint
- Tests include error paths; shutdown/cancel tests for workers
- Capsule checklist on review
References
awesome-guidelines/references/go-style-learning-note.md
awesome-guidelines/references/go-style-formatting-naming.md
awesome-guidelines/references/go-style-errors-flow.md
awesome-guidelines/references/go-style-interfaces-apis.md
awesome-guidelines/references/go-style-concurrency-context.md
1---2name: go-coding-practices3description: Use when reviewing Go formatting, error handling, API boundaries, or goroutine lifetimes; apply project conventions and distinguish ordinary errors from invariant failures.4---56# Go Coding Practices78Application skill for Go style learning (from the archived `awesome-guidelines` style capsules). For service layout or framework patterns, follow project conventions and stack capsules in `skills/*-foundation`.910## Core Principle1112Go code should be **gofmt-clear, error-explicit, and concurrency-obvious**, interfaces earned at the consumer, not invented at the producer.1314## When to Use / NOT1516- Writing or reviewing Go packages, CLIs, or services.17- Setting up `gofmt`, `go vet`, `staticcheck` in CI.1819**NOT when:**2021- Non-Go code.22- Generated protobuf/grpc stubs, validate generators, not hand-edits.2324## Workflow25261. **Format & names**, gofmt, MixedCaps, context-aware locals (`go-style-formatting-naming.md`).272. **Errors**, ordinary failures usually return `error`; preserve the project28 policy for panic/recover at invariant or framework boundaries. Consult29 `go-style-errors-flow.md` for source-specific options.303. **APIs**, concrete returns, small consumer interfaces, named external literals (`go-style-interfaces-apis.md`).314. **Concurrency**, make goroutine lifetime, cancellation, and synchronization32 explicit. Use context where needed; assess shared mutable state rather than33 banning every global (`go-style-concurrency-context.md`).345. **Verify**, use the project's test/vet/lint commands on changed packages;35 additional tools are options, not automatic setup work.3637## Red Flags3839- Ordinary recoverable failures unexpectedly escaping as panics40- Ignored `err` without comment41- Exported mega-interfaces for "clean architecture"42- `go func()` with no shutdown43- Snake_case or skipping gofmt44- Positional struct literal for imported types4546## Verification4748- `gofmt -l` clean; `go vet ./...`; project staticcheck/golangci-lint49- Tests include error paths; shutdown/cancel tests for workers50- Capsule checklist on review515253## References5455- `awesome-guidelines/references/go-style-learning-note.md`56- `awesome-guidelines/references/go-style-formatting-naming.md`57- `awesome-guidelines/references/go-style-errors-flow.md`58- `awesome-guidelines/references/go-style-interfaces-apis.md`59- `awesome-guidelines/references/go-style-concurrency-context.md`