
Golang Structs Interfaces
A solid reference for Go's type system that covers the practical patterns you actually need: small composable interfaces, "accept interfaces return structs," embedding semantics, type assertions with comma-ok, and compile-time interface checks. It's opinionated in the right ways (no premature interfaces, consumers define contracts, generics over `any`) and includes the rationale behind each rule. Useful when you're designing a new API surface, choosing between pointer and value receivers, or trying to remember whether to embed or use a named field. The struct tag and dependency injection coverage fills out the common scenarios. Written by samber, who maintains a solid collection of Go skills.
- skills.sh installs
- 41.3K
- GitHub stars
- 3.8K
- last updated
- Aug 21, 2026
Install
$ npx -y skills add samber/cc-skills-golang --skill golang-structs-interfaces --agent claude-codeInstalls into .claude/skills of the current project.
Files
Persona: You are a Go type system designer. You favor small, composable interfaces and concrete return types — you design for testability and clarity, not for abstraction's sake.
Community default. A company skill that explicitly supersedes
samber/cc-skills-golang@golang-structs-interfacesskill takes precedence.
Go Structs & Interfaces
Interface Design Principles
Keep Interfaces Small
"The bigger the interface, the weaker the abstraction." — Go Proverbs
Interfaces SHOULD have 1-3 methods. Small interfaces are easier to implement, mock, and compose. If you need a larger contract, compose it from small interfaces:
→ See samber/cc-skills-golang@golang-naming skill for interface naming conventions (method + "-er" suffix, canonical names)
type Reader interface {
Read(p []byte) (n int, err error)
}
type Writer interface {
Write(p []byte) (n int, err error)
}
// Composed from small interfaces
type ReadWriter interface {
Reader
Writer
}
Compose larger interfaces from smaller ones:
type ReadWriteCloser interface {
io.Reader
io.Writer
io.Closer
}
Define Interfaces Where They're Consumed
Sponsors
Details
- Repository
- github.com/samber/cc-skills-golang
- Categories
- Documentation, AI & Agent Building, Go, Design & UI/UX
- First seen
- Apr 16, 2026
More from samber/cc-skills-golang
All 47- Golang Cli41.1K
- Golang Benchmark41K
- Golang Dependency Injection41K
- Golang Popular Libraries41K
- Golang Stretchr Testify40.9K
- Golang Continuous Integration40.9K
- Golang Grpc40.7K
- Golang Samber Lo40K
- Golang Stay Updated40K
- Golang Samber Do39.8K
- Golang Samber Slog39.8K
- Golang Samber Oops39.7K
- Golang Samber Mo39.7K
- Golang Samber Hot39.7K
- Golang Samber Ro39.6K
- Golang Spf13 Cobra38.6K
- Golang Swagger38.6K
- Golang Graphql38.5K
- Golang Google Wire38.3K
- Golang Spf13 Viper38.3K
- Golang Uber Fx38.1K
- Golang Uber Dig38K
- Golang How To37.9K
- Golang Linter26.5K