What problem does it solve?
It prevents common Go design pitfalls by guiding how to structure types and contracts so code stays clear, composable, and testable as systems grow.
Core Features & Use Cases
- Keep interfaces small and composable: Prefer 1–3 method interfaces and compose larger ones via smaller interfaces for easier mocking and reasoning.
- Accept interfaces, return structs: Use interfaces for inputs (dependencies/capabilities) while constructors and functions return concrete types for direct field/method access.
- Use correct interface mechanics: Apply compile-time interface checks, safe type assertions (comma-ok), type switches, and optional capability checks via additional interface assertions.
- Embed vs named fields: Embed to promote a full “is-a” API surface, use named fields to keep “has-a” dependencies internal.
- Safer struct behavior: Make zero values useful via lazy initialization, keep receiver types consistent (pointer vs value), and prevent accidental copying with the
noCopy sentinel when needed.
Quick Start
Ask the agent to review your Go types and recommend concrete changes to interface sizes, constructor signatures, embedding choices, and pointer/value receiver consistency for your specific codebase.