Idiomatic Go patterns and best practices for building robust, efficient, and maintainable applications.
When to Activate
- Writing new Go code
- Reviewing Go code
- Refactoring existing Go code
- Designing Go packages/modules
Core Principles
1. Simplicity and Clarity
Go favors simplicity over cleverness. Code should be obvious and easy to read.
2. Make the Zero Value Useful
3. Accept Interfaces, Return Structs
Error Handling Patterns
Error Wrapping with Context
Custom Error Types
Concurrency Patterns
Worker Pool
Context for Cancellation and Timeouts
Graceful Shutdown
Interface Design
Small, Focused Interfaces
Quick Reference: Go Idioms
Go code should be boring in the best way - predictable, consistent, and easy to understand. When in doubt, keep it simple.