
Go Interfaces
Go interfaces guidance for accepting interfaces, returning concrete types, and safe type assertions.
- CCM score
- 69 of 100
- skills.sh installs
- 1.4K
- GitHub stars
- 197
- last updated
- Aug 21, 2026
Own this skill? Claim it
What it does
- Covers accept-interfaces and return-concrete-types design, hiding implementations behind interfaces, comma-ok assertions, type switches, and embedding
- Includes
scripts/check-interface-compliance.shto find exported interfaces that need compile-timevar _ I = (*T)(nil)checks, plus reference notes on embedding and receiver types - Enforces consumer-owned interfaces and warns against defining interfaces before a real usage example exists
- Designed for Go projects that need mockable boundaries or abstraction decisions; defers generics-based polymorphism to go-generics
Install
$ npx -y skills add cxuu/golang-skills --skill go-interfaces -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
Files
Go Interfaces and Composition
Resource Routing
scripts/check-interface-compliance.sh- Run as a heuristic to find exported interfaces that may need compile-time assertions.scripts/check-interface-compliance.go- Implementation helper invoked bycheck-interface-compliance.sh; patch this when changing method-set analysis.references/EMBEDDING.md- Read when embedding interfaces or structs in public APIs.references/RECEIVER-TYPE.md- Read when pointer/value receivers affect interface satisfaction.
Accept Interfaces, Return Concrete Types
Interfaces belong in the package that consumes values, not the package that implements them. Return concrete (usually pointer or struct) types from constructors so new methods can be added without refactoring.
// Good: consumer defines the interface it needs
package consumer
type Thinger interface { Thing() bool }
func Foo(t Thinger) string { ... }
// Good: producer returns concrete type
package producer
type Thinger struct{ ... }
func (t Thinger) Thing() bool { ... }
func NewThinger() Thinger { return Thinger{ ... } }
Details
- Repository
- github.com/cxuu/golang-skills
- Category
- Go
- First seen
- May 16, 2026
More from cxuu/golang-skills
All 20- Go Linting1.4K
- Go Style Core1.4K
- Go Documentation1.4K
- Go Context1.4K
- Go Performance1.4K
- Go Naming1.3K
- Go Defensive1.3K
- Go Packages1.3K
- Go Functional Options1.3K
- Go Data Structures1.3K
- Go Control Flow1.3K
- Go Logging1.1K
- Go Generics1.1K
- Go Functions1.1K
- Go Declarations1.1K
- Go Code Review1.8K
- Go Testing1.5K
- Go Error Handling1.4K
- Go Concurrency1.4K
Similar to Go Interfaces
More Go
golang-structs-interfacessamber/cc-skills-golang42.2K installsGo struct and interface design guide covering composition, embedding, type assertions, and pointer vs value receivers.
go-genericscxuu/golang-skills1.1K installsConcrete guidance for deciding when Go generics pay off, with constraint and type-alias rules and common pitfalls.
go-functionscxuu/golang-skills1.1K installsGo function design rules covering file ordering, signature wrapping, interface parameters, and Printf-style naming.
golang-patternsaffaan-m/ecc18.1K installsIdiomatic Go patterns covering error handling, concurrency, and interface design for maintainable applications.
golang-design-patternssamber/cc-skills-golang44.8K installsIdiomatic Go design patterns covering constructors, error flow, lifecycle, and architecture choices for production code.
Effective Goopenshift/hypershift399 installsIdiomatic Go guidance drawn from the official Effective Go guide for writing, reviewing, and refactoring code.