Go Design Patterns
Master software design patterns in Go with interactive examples and production-ready code. 27 patterns across 4 categories.
Start LearningCreational Patterns
Object creation mechanisms
Singleton
Ensures a class has only one instance and provides global access to it.
Factory Method
Defines an interface for creating objects, letting subclasses decide which class to instantiate.
Abstract Factory
Creates families of related objects without specifying their concrete classes.
Builder
Separates complex object construction from its representation.
Prototype
Creates new objects by copying an existing object (prototype).
Structural Patterns
Compose objects into larger structures
Adapter
Allows incompatible interfaces to work together.
Bridge
Separates abstraction from implementation so both can vary independently.
Composite
Composes objects into tree structures to represent part-whole hierarchies.
Decorator
Attaches additional responsibilities to objects dynamically.
Facade
Provides a simplified interface to a complex subsystem.
Flyweight
Shares common state between multiple objects to reduce memory usage.
Proxy
Provides a surrogate or placeholder for another object.
Behavioral Patterns
Communication between objects
Chain of Responsibility
Passes requests along a chain of handlers.
Command
Encapsulates a request as an object.
Iterator
Provides sequential access to elements without exposing underlying structure.
Mediator
Defines an object that encapsulates how objects interact.
Memento
Captures and restores an object's internal state.
Observer
Defines a subscription mechanism to notify multiple objects about events.
State
Allows an object to alter its behavior when its internal state changes.
Strategy
Defines a family of algorithms and makes them interchangeable.
Template Method
Defines the skeleton of an algorithm, letting subclasses fill in specific steps.
Visitor
Separates algorithms from the objects on which they operate.
Concurrency Patterns
Go-specific patterns for goroutines
Worker Pool
Manages a pool of goroutines to process tasks concurrently.
Fan-Out/Fan-In
Distributes work across multiple goroutines and collects results.
Pipeline
Chains processing stages connected by channels.
Semaphore
Controls access to resources by multiple goroutines.
Context
Carries deadlines, cancellation signals, and request-scoped values.