go-interfaces▌
cxuu/golang-skills · updated Apr 8, 2026
MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.
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.
Go Interfaces and Composition
Available Scripts
scripts/check-interface-compliance.sh— Finds exported interfaces missing compile-time compliance checks (var _ I = (*T)(nil)). Runbash scripts/check-interface-compliance.sh --helpfor options.
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{ ... } }
// Bad: producer defines and returns its own interface
package producer
type Thinger interface { Thing() bool }
type defaultThinger struct{ ... }
func NewThinger() Thinger { return defaultThinger{ ... } }
Do not define interfaces before they are used. Without a realistic example of usage, it is too difficult to see whether an interface is even necessary.
Generality: Hide Implementation, Expose Interface
If a type exists only to implement an interface with no exported methods beyond that interface, return the interface from constructors to hide the implementation:
func NewHash() hash.Hash32 {
return &myHash{} // unexported type
}
Benefits: implementation can change without affecting callers, substituting algorithms requires only changing the constructor call.
Type Assertions: Comma-Ok Idiom
Without checking, a failed assertion causes a runtime panic. Always use the comma-ok idiom to test safely:
str, ok := value.(string)
if ok {
fmt.Printf("string value is: %q\n", str)
}
To check if a value implements an interface:
if _, ok := val.(json.Marshaler); ok {
fmt.Printf("value %v implements json.Marshaler\n", val)
}
Type Switch
It's idiomatic to reuse the variable name (t := t.(type)) — the variable has
the correct type in each case branch. When a case lists multiple types
(case int, int64:), the variable has the interface type.
Embedding
Avoid embedding types in public structs — the inner type's full method set becomes part of your public API. Use unexported fields instead.
Read references/EMBEDDING.md when using struct embedding for composition, overriding embedded methods, resolving name conflicts, applying the HandlerFunc adapter pattern, or deciding whether to embed in public API types.
Interface Satisfaction Checks
Use a blank identifier assignment to verify a type implements an interface at compile time:
var _ json.Marshaler = (*RawMessage)(nil)
This causes a compile error if *RawMessage doesn't implement json.Marshaler.
Use this pattern when:
- There are no static conversions that would verify the interface automatically
- The type must satisfy an interface for correct behavior (e.g., custom JSON marshaling)
- Interface changes should break compilation, not silently degrade
Don't add these checks for every interface — only when no other static conversion would catch the error.
Validation: After defining interfaces or implementations, run
bash scripts/check-interface-compliance.shto verify all concrete types have compile-timevar _ I = (*T)(nil)checks.
Receiver Type
If in doubt, use a pointer receiver. Don't mix receiver types on a single
type — if any method needs a pointer, use pointers for all methods. Use value
receivers only for small, immutable types (Point, time.Time) or basic types.
Read references/RECEIVER-TYPE.md when deciding between pointer and value receivers for a new type, especially for types with sync primitives or large structs.
Quick Reference
| Concept | Pattern | Notes |
|---|---|---|
| Consumer owns interface | Define interfaces where used | Not in the implementing package |
| Safe type assertion | v, ok := x.(Type) |
Returns zero value + false |
| Type switch | switch v := x.(type) |
Variable has correct type per case |
| Interface embedding | type RW interface { Reader; Writer } |
Union of methods |
| Struct embedding | type S struct { *T } |
Promotes T's methods |
| Interface check | var _ I = (*T)(nil) |
Compile-time verification |
| Generality | Return interface from constructor | Hide implementation |
Related Skills
- Interface naming: See go-naming when naming interfaces (the
-ersuffix convention) or choosing receiver names - Error types: See go-error-handling when implementing the
errorinterface, custom error types, orerrors.Asmatching - Generics vs interfaces: See go-generics when deciding whether generics are needed or an interface already suffices
- Functional options: See go-functional-options when using an interface-based Option pattern for flexible constructors
- Compile-time checks: See go-defensive when adding
var _ I = (*T)(nil)satisfaction checks at API boundaries
How to use go-interfaces on Cursor
AI-first code editor with Composer
Prerequisites
Before installing skills in Cursor, ensure your development environment meets these requirements:
- ›Cursor installed and configured on your development machine
- ›Node.js version 16.0+ with npm package manager (verify with
node --version) - ›Active project directory or workspace where you want to add go-interfaces
Execute installation command
Execute the skills CLI command in your project's root directory to begin installation:
The skills CLI fetches go-interfaces from GitHub repository cxuu/golang-skills and configures it for Cursor.
Select Cursor when prompted
The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:
Verify installation
Confirm successful installation by checking the skill directory location:
Reload or restart Cursor to activate go-interfaces. Access the skill through slash commands (e.g., /go-interfaces) or your agent's skill management interface.
Security & Verification Notice
We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.
Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.
List & Monetize Your Skill
Submit your Claude Code skill and start earning
Use Cases▌
Task Automation & Efficiency
Automate repetitive workflows and reduce manual effort
Example
Generate reports, summarize documents, draft communications
Save 3-5 hours per week on routine tasks
Knowledge Enhancement
Learn new skills, understand complex topics, get expert guidance
Example
Explain concepts, provide examples, suggest learning resources
Accelerate learning and skill development by 2x
Quality Improvement
Enhance output quality through reviews, suggestions, and refinements
Example
Review drafts, suggest improvements, catch errors
Improve work quality by 30-40% with less effort
Implementation Guide▌
Prerequisites
- ›Claude Desktop or compatible AI client with skill support
- ›Clear understanding of task or problem to solve
- ›Willingness to iterate and refine outputs
Time Estimate
15-45 minutes depending on use case complexity
Installation Steps
- 1.Install skill using provided installation command
- 2.Test with simple use case relevant to your work
- 3.Evaluate output quality and relevance
- 4.Iterate on prompts to improve results
- 5.Integrate into regular workflow if valuable
Common Pitfalls
- ⚠Expecting perfect results without iteration
- ⚠Not providing enough context in prompts
- ⚠Using skill for tasks outside its intended scope
- ⚠Accepting outputs without review and validation
Best Practices▌
✓ Do
- +Start with clear, specific prompts
- +Provide relevant context and constraints
- +Review and refine all outputs before using
- +Iterate to improve output quality
- +Document successful prompt patterns
✗ Don't
- −Don't use without understanding skill limitations
- −Don't skip validation of outputs
- −Don't share sensitive information in prompts
- −Don't expect skill to replace human judgment
💡 Pro Tips
- ★Be specific about desired format and style
- ★Ask for multiple options to choose from
- ★Request explanations to understand reasoning
- ★Combine AI efficiency with human expertise
When to Use This▌
✓ Use When
Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.
✗ Avoid When
Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.
Learning Path▌
- 1Familiarize yourself with skill capabilities and limitations
- 2Start with low-risk, non-critical tasks
- 3Progress to more complex and valuable use cases
- 4Build expertise through regular use and experimentation
Discussion
Product Hunt–style comments (not star reviews)- No comments yet — start the thread.
Ratings
4.7★★★★★53 reviews- ★★★★★Layla Sharma· Dec 28, 2024
Keeps context tight: go-interfaces is the kind of skill you can hand to a new teammate without a long onboarding doc.
- ★★★★★Neel Bhatia· Dec 16, 2024
go-interfaces fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
- ★★★★★Ishan Wang· Dec 16, 2024
Keeps context tight: go-interfaces is the kind of skill you can hand to a new teammate without a long onboarding doc.
- ★★★★★Yusuf Verma· Dec 12, 2024
go-interfaces has been reliable in day-to-day use. Documentation quality is above average for community skills.
- ★★★★★Chaitanya Patil· Dec 4, 2024
Registry listing for go-interfaces matched our evaluation — installs cleanly and behaves as described in the markdown.
- ★★★★★Piyush G· Nov 23, 2024
Solid pick for teams standardizing on skills: go-interfaces is focused, and the summary matches what you get after install.
- ★★★★★Benjamin Ramirez· Nov 19, 2024
go-interfaces has been reliable in day-to-day use. Documentation quality is above average for community skills.
- ★★★★★Neel Ghosh· Nov 7, 2024
We added go-interfaces from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.
- ★★★★★Yuki Mehta· Nov 3, 2024
Keeps context tight: go-interfaces is the kind of skill you can hand to a new teammate without a long onboarding doc.
- ★★★★★Ishan Li· Oct 26, 2024
Keeps context tight: go-interfaces is the kind of skill you can hand to a new teammate without a long onboarding doc.
showing 1-10 of 53