accept-interfaces-return-structs
Installation
SKILL.md
Accept Interfaces, Return Structs
The fundamental Go interface design principle: functions should accept interfaces but return concrete types.
The Pattern
CORRECT - Accept interface, return concrete
type Storage interface {
Save(data []byte) error
}
func NewProcessor(s Storage) *Processor {
return &Processor{storage: s}
}