
Golang Structs Interfaces
Go struct and interface design guide covering composition, embedding, type assertions, and pointer vs value receivers.
- skills.sh installs
- 41.7K
- GitHub stars
- 3.9K
- last updated
- Aug 21, 2026
Own this skill? Claim it
What it does
- Covers small interface design, consumer-side interface definition, and when to embed structs versus use named fields
- Includes a compile-time interface check (
var _ io.ReadWriter = (*MyBuffer)(nil)), type switch and comma-ok assertion patterns, and struct field tags - Enforces "accept interfaces, return structs" and discourages premature interfaces with a single implementation
- Designed for Go developers who need guidance on type design when writing or reviewing
*.gofiles
Install
$ npx -y skills add samber/cc-skills-golang --skill golang-structs-interfaces -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
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
Details
- Repository
- github.com/samber/cc-skills-golang
- Category
- Go
- First seen
- Apr 16, 2026
More from samber/cc-skills-golang
All 47- Golang Cli41.5K
- Golang Benchmark41.5K
- Golang Dependency Injection41.4K
- Golang Popular Libraries41.4K
- Golang Stretchr Testify41.3K
- Golang Continuous Integration41.3K
- Golang Grpc41.1K
- Golang Samber Lo40.4K
- Golang Stay Updated40.3K
- Golang Samber Do40.2K
- Golang Samber Slog40.1K
- Golang Samber Oops40K
- Golang Samber Mo40K
- Golang Samber Hot40K
- Golang Samber Ro39.9K
- Golang Spf13 Cobra39K
- Golang Swagger39K
- Golang Graphql38.8K
- Golang Google Wire38.7K
- Golang Spf13 Viper38.7K
- Golang Uber Fx38.4K
- Golang Uber Dig38.4K
- Golang How To38.3K
- Golang Linter26.5K
Similar to Golang Structs Interfaces
More Go
go-interfacescxuu/golang-skills1.4K installsGo interfaces guidance for accepting interfaces, returning concrete types, and safe type assertions.
golang-design-patternssamber/cc-skills-golang44.3K installsIdiomatic Go design patterns covering constructors, error flow, lifecycle, and architecture choices for production code.
golang-data-structuressamber/cc-skills-golang42.3K installsReference guide covering Go slices, maps, arrays, container packages, generics, and pointer types with selection guidance.
go-declarationscxuu/golang-skills1.1K installsGo declaration style guide covering var vs :=, iota enums, scope, struct and map initialization, and literal formatting.
Effective Goopenshift/hypershift555 starsIdiomatic Go guidance drawn from the official Effective Go guide for writing, reviewing, and refactoring code.