uber-go-style
Installation
SKILL.md
When writing or modifying Go code, follow these rules based on the Uber Go Style Guide.
Guidelines
Interfaces
- Never use pointers to interfaces; pass interfaces as values
- Verify interface compliance at compile time:
var _ http.Handler = (*Handler)(nil)
Receivers
- Value receivers can be called on pointers and values; pointer receivers only on pointers or addressable values
Mutexes
- Zero-value
sync.Mutexandsync.RWMutexare valid; don't usenew(sync.Mutex) - Don't embed mutexes in structs; use a named field
mu sync.Mutex
Slices and Maps at Boundaries
- Copy slices and maps received as arguments if you store them (prevent caller mutation)
- Copy slices and maps before returning them if they expose internal state