Golang Patterns Skill
- Installs
- 18.4k
- Repo stars
- 314k
- Repo updated
- Nov 30, 2026
TL;DR
golang-patterns is an ECC Go skill that applies idiomatic design patterns including functional options, small interfaces, and concurrency primitives for developers writing maintainable Go services.
Install if
Go developers refactoring or authoring services who want ECC-curated idioms instead of ad hoc struct wiring.
Skip if
Non-Go codebases or teams needing framework-specific guides like Gin or Echo routing tutorials only.
npx skills add https://github.com/affaan-m/ECC --skill golang-patternsTry it first through the Skillselion MCP - nothing to install, nothing on disk.
1. Add the remote connector:
claude mcp add --transport http skillselion https://mcp.skillselion.com/mcp2. Ask your agent:
Use Skillselion load_skill to load skill:affaan-m/ecc#golang-patterns (Golang Patterns) and follow it.Try it first through the Skillselion MCP - nothing to install, nothing on disk.
1. Add this URL as a custom connector (Claude.ai, ChatGPT or Cursor):
https://mcp.skillselion.com/mcp2. Ask your agent:
Use Skillselion load_skill to load skill:affaan-m/ecc#golang-patterns (Golang Patterns) and follow it.On this page
What golang-patterns covers
- Enforces simplicity and clarity over clever code
- Teaches making the zero value useful for types and structs
- Guides error handling, package design, and module conventions
- Activates for writing, reviewing, refactoring, or designing Go code
- Provides concrete good-vs-bad code examples for every principle
golang-patterns by the numbers
| All-time installs | 18,422 (18.4k) | skills.sh registry |
|---|---|---|
| Repo stars | ★ 314k | GitHub |
| Repo last updated | November 30, 2026 | GitHub |
| Repository | affaan-m/ECC ↗ | |
Data as of Dec 1, 2026 (Skillselion catalog sync)
What does the Golang Patterns skill produce?
Refactored Go modules with functional options, interface boundaries, and organized package layouts.
- Idiomatic Go refactors
- Functional options constructors
What files ship with golang-patterns?
Go Patterns
This skill provides comprehensive Go patterns extending common design principles with Go-specific idioms.
Functional Options
Use the functional options pattern for flexible constructor configuration:
type Option func(*Server)
func WithPort(port int) Option {
return func(s *Server) { s.port = port }
}
func NewServer(opts ...Option) *Server {
s := &Server{port: 8080}
for _, opt := range opts {
opt(s)
}
return s
}Benefits:
- Backward compatible API evolution
- Optional parameters with defaults
- Self-documenting configuration
Small Interfaces
Define interfaces where they are used, not where they are implemented.
Principle: Accept interfaces, return structs
// Good: Small, focused interface defined at point of use
type UserStore interface {
GetUser(id string) (*User, error)
}
func ProcessUser(store UserStore, id string) error {
user, err := store.GetUser(id)
// ...
}Benefits:
- Easier testing and mocking
- Loose coupling
- Clear dependencies
Dependency Injection
Use constructor functions to inject dependencies:
func NewUserService(repo UserRepository, logger Logger) *UserService {
return &UserService{
repo: repo,
logger: logger,
}
}Pattern:
- Constructor functions (New* prefix)
- Explicit dependencies as parameters
- Return concrete types
- Validate dependencies in constructor
Concurrency Patterns
Worker Pool
func workerPool(jobs <-chan Job, results chan<- Result, workers int) {
var wg sync.WaitGroup
for i := 0; i < workers; i++ {
wg.Add(1)
go func() {
defer wg.Done()
for job := range jobs {
results <- processJob(job)
}
}()
}
wg.Wait()
close(results)
}Context Propagation
Always pass context as first parameter:
func FetchUser(ctx context.Context, id string) (*User, error) {
// Check context cancellation
select {
case <-ctx.Done():
return nil, ctx.Err()
default:
}
// ... fetch logic
}Error Handling
Error Wrapping
if err != nil {
return fmt.Errorf("failed to fetch user %s: %w", id, err)
}Custom Errors
type ValidationError struct {
Field string
Msg string
}
func (e *ValidationError) Error() string {
return fmt.Sprintf("%s: %s", e.Field, e.Msg)
}Sentinel Errors
var (
ErrNotFound = errors.New("not found")
ErrInvalid = errors.New("invalid input")
)
// Check with errors.Is
if errors.Is(err, ErrNotFound) {
// handle not found
}Package Organization
Structure
project/
├── cmd/ # Main applications
│ └── server/
│ └── main.go
├── internal/ # Private application code
│ ├── domain/ # Business logic
│ ├── handler/ # HTTP handlers
│ └── repository/ # Data access
└── pkg/ # Public librariesNaming Conventions
- Package names: lowercase, single word
- Avoid stutter:
user.Usernotuser.UserModel - Use
internal/for private code - Keep
mainpackage minimal
Testing Patterns
Table-Driven Tests
func TestValidate(t *testing.T) {
tests := []struct {
name string
input string
wantErr bool
}{
{"valid", "test@example.com", false},
{"invalid", "not-an-email", true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := Validate(tt.input)
if (err != nil) != tt.wantErr {
t.Errorf("got error %v, wantErr %v", err, tt.wantErr)
}
})
}
}Test Helpers
func testDB(t *testing.T) *sql.DB {
t.Helper()
db, err := sql.Open("sqlite3", ":memory:")
if err != nil {
t.Fatalf("failed to open test db: %v", err)
}
t.Cleanup(func() { db.Close() })
return db
}When to Use This Skill
- Designing Go APIs and packages
- Implementing concurrent systems
- Structuring Go projects
- Writing idiomatic Go code
- Refactoring Go codebases
Which skills are related to golang-patterns?
What are the Golang Patterns skill forks?
Golang Patterns has 1 known copy in the catalog totaling 0 installs. They canonicalize to this original listing.
How does golang-patterns compare?
Use golang-patterns over generic design-pattern skills when the codebase is Go and needs module-level idioms tied to go.mod structure.
Golang Patterns skill FAQ
Who is the Golang Patterns skill for?
Go developers refactoring or authoring services who want ECC-curated idioms instead of ad hoc struct wiring. Skip if: Non-Go codebases or teams needing framework-specific guides like Gin or Echo routing tutorials only.
When should I use golang-patterns?
An agent edits .go files or go.mod and needs idiomatic Go structure, options pattern, or concurrency guidance.
Which files trigger golang-patterns?
golang-patterns metadata globs target */.go, /go.mod, and /go.sum so agents apply ECC Go idioms when editing Go source or module files.
What patterns does golang-patterns cover?
golang-patterns covers functional options, small interfaces, dependency injection, concurrency, error handling, and package organization for maintainable Go code.
Add a golang-patterns badge
Show developers this skill is listed on Skillselion. Paste this into your README.