Agent skill · software engineering · affaan-m

golang-patterns

Go-specific design patterns and best practices including functional options, small interfaces, dependency injection, concurrency patterns, error handling, and package organization. Use when working with Go code to apply idiomatic Go patterns.

Why this skill is useful

Provides Go-specific design patterns and idioms that enhance idiomatic Go programming, which the AI may not reliably generate on its own.

What it needs

About 2k tokens when loaded. Last updated 2026-08-06. 238,342 stars on the source repository.

What this skill does

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: 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 Benefits: Easier testing and mocking Loose coupling Clear dependencies Dependency Injection Use constructor functions to inject dependencies: Pattern: Constructor functions (New prefix) Explicit dependencies as parameters Return concrete types Validate dependencies in constructor Concurrency Patterns Worker Pool Context Propagation Always pass context as first parameter: Error Handling Error Wrapping Custom Errors Sentinel Errors Package Organization Structure Naming Conventions Package names: lowercase, single word Avoid stutter: user.User not user.UserModel Use internal/ for private code Keep main package minimal Testing Patterns Table-Driven Tests Test Helpers When to Use This Skill Designing Go APIs and packages Implementing concurrent systems Structuring Go projects Writing idiomatic Go code Refactoring Go codebases

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills affaan-m/golang-patterns--d8ab8f

View the source on GitHub

Browse the @skills marketplace