go-interfaces

Guide Go interface design with consumer-defined interfaces and consistent receivers.

8|Updated Jun 5, 2026
One-click install
npx skills add https://github.com/muratmirgun/gophers --skill go-interfaces-muratmirgun
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-interfaces
Source: https://github.com/muratmirgun/gophers/tree/main/skills/go-interfaces
Command: npx skills add https://github.com/muratmirgun/gophers --skill go-interfaces-muratmirgun

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you avoid oversized, producer-owned abstractions in Go by guiding you toward small, consumer-defined interfaces and consistent receiver choices. It reduces coupling, improves testability, and prevents interface and embedding mistakes that are hard to unwind later.

Core Features & Use Cases

  • Consumer-owned interfaces: Define interfaces in the package that uses them, not where they are implemented.
  • Concrete returns, small contracts: Return concrete types from constructors while keeping interfaces minimal and composable.
  • Composition and receivers: Use struct embedding deliberately and keep pointer or value receiver choices consistent.
  • Safety checks: Apply compile-time interface satisfaction checks and comma-ok type assertions to prevent runtime surprises.
  • Use cases: Designing service seams, adding test fakes, deciding whether to extract an interface, or reviewing exported types for accidental API leaks.

Quick Start

Ask for help redesigning a Go package boundary so it uses a small consumer-owned interface and consistent receiver methods.

Frequently Asked Questions about go-interfaces

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I design small Go interfaces that don't leak unnecessary abstractions?

Design small Go interfaces by defining consumer-owned contracts in the package that uses them, returning concrete types from constructors, and keeping abstractions minimal to reduce coupling and prevent accidental API leaks.

When should I define interfaces in the consumer package vs the producer package in Go?

Define interfaces in the consumer package in Go to avoid producer-owned abstractions and oversized contracts. This consumer-defined approach ensures interfaces are extracted only when multiple implementations are needed, improving testability.

What is the best way to choose between pointer and value receivers in Go?

The best way to choose between pointer and value receivers in Go is to keep the selection deliberate and consistent across a type's methods. This prevents inconsistent receiver patterns and avoids compile-time interface satisfaction issues.

How do I use compile-time interface checks and type assertions safely in Go?

Use compile-time interface checks safely in Go by assigning a concrete type to an interface variable at package scope. Apply comma-ok type assertions during runtime checks to prevent unexpected panics and verify type implementations.

How do I use struct embedding deliberately to compose Go interfaces?

Use struct embedding deliberately in Go to compose types while keeping interfaces minimal. This approach ensures package boundaries remain clean and prevents embedding mistakes that are difficult to unwind in production Go code.

How do I use struct embedding deliberately to compose Go interfaces?

Use struct embedding deliberately in Go to compose types while keeping interfaces minimal. This approach ensures package boundaries remain clean and prevents embedding mistakes that are difficult to unwind in production Go code.