From claude-resources
Go interface patterns. Accept interfaces/return structs, consumer-side definition, interface segregation, generics vs interfaces. 100% Go-specific.
npx claudepluginhub deandum/claude-resources --plugin go-skillsThis skill uses the workspace's default tool permissions.
The bigger the interface, the weaker the abstraction.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Guides agent creation for Claude Code plugins with file templates, frontmatter specs (name, description, model), triggering examples, system prompts, and best practices.
The bigger the interface, the weaker the abstraction.
Don't create interfaces until needed. Interfaces should be discovered, not designed upfront.
// Interface at consumer side
type Repository interface {
FindByID(ctx context.Context, id int64) (*User, error)
Save(ctx context.Context, user *User) error
}
// Function accepts interface, returns concrete
func GetUserProfile(ctx context.Context, repo Repository, id int64) (*User, error) {
return repo.FindByID(ctx, id)
}
// Small, focused interfaces
type UserFinder interface { FindByID(ctx context.Context, id int64) (*User, error) }
type UserCreator interface { Create(ctx context.Context, user *User) error }
// Compose when needed
type UserRepository interface { UserFinder; UserCreator }
Ideal: 1-3 methods. Questionable: 5+.
var _ Storage = (*FileStorage)(nil)
| Interface | Generics | Concrete |
|---|---|---|
| Multiple impls exist | Type-safe containers | Single implementation |
| Behavior abstraction | Algorithms across types | No abstraction needed |
| Testing with mocks | Collections (slice/map) | Simplicity preferred |
Default to concrete. Add interface when testing or multiple impls needed.
Accept io.Reader, io.Writer, io.Closer, fmt.Stringer for maximum compatibility.
Keep interfaces small -> easy to mock. Use function-based mocks (see go/testing).
-er suffix (Reader, Writer, Closer)UserRepository)Interface suffixvar _ I = (*T)(nil))