Go Interfaces

Go interface design patterns and best practices Use when this capability is needed.

tomevault-io Updated

File contents

Interface Design

Master Go's approach to interfaces: implicit satisfaction, consumer-driven design, and composition patterns.

Route by Concern

  • Accept/return patterns → see design/

    • Accept interfaces, return structs principle
    • When to deviate from the rule
  • Interface pollution → see pollution/

    • Detecting unnecessary abstractions
    • Premature interface creation
  • Embedding patterns → see embedding/

    • Interface composition techniques
    • Method set expansion

Quick Check

  • Interface defined by consumer, not producer
  • Keep interfaces small (<5 methods)
  • Return concrete types from functions
  • No interface{} unless truly necessary

Converted and distributed by TomeVault — claim your Tome and manage your conversions.

tomevault-io/skills-registry/tree/main/jamesprial--claudefiles--interfaces commit 5c21bf55a1

Frequently asked questions

npx skillmds@latest add tomevault-io/go-interfaces-2