
Go Interfaces
Covers the practical side of Go interfaces: where to define them (consumer's package, not producer's), when to use pointer versus value receivers, and how to write compile-time satisfaction checks with the `var _ I = (*T)(nil)` pattern. Includes a script that scans your codebase for missing interface compliance checks, which is genuinely useful for catching drift. The "accept interfaces, return concrete types" guidance is the most important bit here, and it's explained clearly with good and bad examples. Also covers type assertions, type switches, and embedding gotchas. If you're writing testable Go or designing package boundaries, this gives you the idioms you need without the usual blog post fluff.
- skills.sh installs
- 1.3K
- GitHub stars
- 193
- last updated
- Aug 21, 2026
Install
$ npx -y skills add cxuu/golang-skills --skill go-interfaces --agent claude-codeInstalls into .claude/skills of the current project.
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{ ... } }
Sponsors
Details
- Repository
- github.com/cxuu/golang-skills
- Categories
- Testing & QA, AI & Agent Building, Go
- First seen
- May 16, 2026
More from cxuu/golang-skills
All 20- Go Documentation1.3K
- Go Style Core1.3K
- Go Performance1.3K
- Go Context1.3K
- Go Naming1.3K
- Go Defensive1.3K
- Go Packages1.3K
- Go Data Structures1.3K
- Go Functional Options1.3K
- Go Control Flow1.3K
- Go Logging1.1K
- Go Functions1.1K
- Go Generics1.1K
- Go Declarations1.1K
- Go Code Review1.8K
- Go Testing1.4K
- Go Error Handling1.3K
- Go Linting1.3K
- Go Concurrency1.3K