golang
Installation
Summary
Production Go code patterns covering error handling, concurrency, naming, testing, and performance.
- Comprehensive error handling guidance: return errors instead of panicking, use error wrapping with
%wfor inspection and%vfor boundaries, join multiple errors witherrors.Join, and handle errors once at the appropriate level - Concurrency best practices: unbuffered or size-1 channels, document goroutine lifetimes, prefer
errgroup.Groupfor concurrent operations, and use typed atomics fromsync/atomic - Naming conventions: MixedCaps always, consistent initialisms (URL not Url), short names for limited scope, one or two-letter receiver names, and avoid repeating package names in identifiers
- Testing patterns: table-driven tests with parallel execution, use
go-cmpfor comparisons,synctestfor deterministic concurrent testing (Go 1.25+), and verify interface compliance at compile time - Performance tips: preallocate slices and maps with known capacity, use
strings.Builderfor concatenation, preferstrconvoverfmt, and leverage standard libraryslicesandmapspackages
SKILL.md
Go Best Practices
Production patterns from Google, Uber, and the Go team. Updated for Go 1.25.
Sub-skills:
skills/go-error-handling,skills/go-concurrency,skills/go-testing,skills/go-performance,skills/go-code-review,skills/go-linting,skills/go-project-layout,skills/go-security. Deep-dive references inreferences/.
Core Principles
Readable code prioritizes these attributes in order:
- Clarity: purpose and rationale are obvious to the reader
- Simplicity: accomplishes the goal in the simplest way
- Concision: high signal to noise ratio
- Maintainability: easy to modify correctly
- Consistency: matches surrounding codebase