What problem does it solve?
This Skill helps you avoid common Go design mistakes when creating structs and interfaces, so your code stays testable, maintainable, and type-safe.
Core Features & Use Cases
- Small, composable interfaces: design 1–3 method interfaces and compose larger contracts when needed.
- Consumer-driven contracts: define interfaces in the package that consumes them, not the package that implements them.
- Constructor return rules: accept interfaces for dependencies, but return concrete types from constructors.
- Correct Go type system practices: use compile-time interface checks, safe type assertions, type switches, and optional capability assertions.
- Struct quality rules: make the zero value useful via lazy initialization, prefer generics over any, and enforce receiver consistency and no-copy safety when required.
- Serialization safety: require exported struct fields in serialized types to have appropriate tags (json/yaml/db/etc.).
Quick Start
Use the golang-structs-interfaces skill to review and improve your Go type design by asking: "Review my structs and interfaces for consumer-defined contracts, small interface sizes, constructor return types, safe assertions, and zero-value correctness, then suggest具体 changes."