go-design-patterns

Implement idiomatic Go design patterns for constructors, factories, and middleware.

64|9|Updated Mar 27, 2026
One-click install
npx skills add https://github.com/eduardo-sl/go-agent-skills --skill go-design-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-design-patterns
Source: https://github.com/eduardo-sl/go-agent-skills/tree/main/skills/%28architecture%29/go-design-patterns
Command: npx skills add https://github.com/eduardo-sl/go-agent-skills --skill go-design-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Go developers often face challenges applying idiomatic design patterns in real codebases; this guide clarifies how to implement patterns like functional options, builders, factories, strategy, and decorators in Go, aligning with the language's composition-focused style.

Core Features & Use Cases

  • Functional Options: flexible constructor configuration with safe defaults.
  • Constructors and Factories: predictable initialization and dependency management.
  • Patterns & Patterns: strategy, builder, factory, middleware chain, and pub/sub patterns adapted for Go contexts.
  • Use Case: structure a Go service with configurable components and clean interfaces.

Quick Start

Apply these patterns to a Go project by refactoring constructors, factories, and middleware to use idiomatic options and composition.

Frequently Asked Questions about go-design-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement idiomatic Go design patterns in a real codebase?

Idiomatic Go design patterns are implemented by favoring composition over inheritance, applying functional options for constructors, and using factories, builders, and middleware chains to structure clean, predictable modules.

What is the functional options pattern in Go and when should I use it?

The functional options pattern in Go provides flexible constructor configuration with safe defaults. Use it when you need customizable component initialization without bloating function signatures or violating interface segregation.

How do I build a middleware chain in Go using composition?

Build a Go middleware chain by linking decorator or strategy patterns to pass requests sequentially. This composition-focused approach avoids premature abstractions and keeps dependency management predictable.

What are common Go anti-patterns to avoid when structuring a service?

Common Go anti-patterns to avoid include creating god interfaces and introducing premature abstractions. Discouraging these ensures your service relies on idiomatic patterns like factory and strategy instead of rigid hierarchies.

Can I use the builder and factory patterns together for Go dependency management?

Yes, you can combine the builder and factory patterns in Go for predictable initialization and dependency management. This approach aligns with Go's composition style to configure components and construct clean interfaces safely.

Why does my Go factory pattern implementation feel overly complex?

Your Go factory pattern implementation likely feels overly complex due to premature abstractions or god interfaces. Refactoring to idiomatic functional options and composition-focused design simplifies initialization and removes unnecessary coupling.