Interactive learning journey
Design Patterns, the Go way
Every classic Gang-of-Four pattern and Go's essential concurrency patterns — explained with clear diagrams, idiomatic Go you can run, and the exact places they hide in the standard library. Built to actually stick.
Progress is saved in your browser — mark a pattern “learned” on its page and watch the bars fill.
How this guide works
One pattern, one page
Each page follows the same rhythm: analogy → problem → diagram → idiomatic Go → trade-offs → quiz. Once you learn the rhythm, every pattern is easy to absorb.
See it, then read it
UML structure and sequence diagrams (rendered with Mermaid) make the relationships obvious before you hit a single line of code.
Go-first, not Java-translated
We show how interfaces, composition and goroutines reshape each classic pattern — and where Go's standard library already uses it.
Made to remember
Runnable examples, a self-check quiz on every page, and progress tracking turn passive reading into a journey you finish.
🚀 New here? Start with the Foundations
Five minutes on what patterns are and why Go does them differently will make every page that follows click into place. Then work top-to-bottom, or jump straight to whatever you need.
Start here
Creational
How objects get made — controlling instantiation so the rest of your code doesn't have to care about concrete types.
Ensure a type has only one instance, and provide a single, well-defined point of access to it.
✦ Complete 3 · Beginner Factory MethodDefine an interface for creating an object, but let the implementation decide which concrete type to instantiate.
✦ Complete 4 · Intermediate Abstract FactoryProvide an interface for creating families of related objects without specifying their concrete types.
✦ Complete 5 · Intermediate BuilderConstruct a complex object step by step, separating how it's built from its final representation.
✦ Complete 6 · Intermediate PrototypeCreate new objects by cloning an existing, configured instance instead of building one from scratch.
✦ CompleteStructural
How objects are composed — assembling types into larger structures while keeping them flexible.
Convert the interface of a type into another interface clients expect, letting otherwise-incompatible types work together.
✦ Complete 8 · Advanced BridgeDecouple an abstraction from its implementation so the two can vary independently, instead of multiplying into N×M types.
✦ Complete 9 · Intermediate CompositeTreat individual objects and compositions of objects uniformly through one common interface.
✦ Complete 10 · Intermediate DecoratorAttach new behavior to an object by wrapping it in another object of the same interface — without changing the original's type.
✦ Complete 11 · Beginner FacadeProvide a single, simplified interface over a complex subsystem, so clients don't have to orchestrate its parts.
✦ Complete 12 · Advanced FlyweightShare common immutable state across many objects to slash memory use, keeping only per-instance data separate.
✦ Complete 13 · Intermediate ProxyProvide a stand-in for another object that implements the same interface, to control access to it.
✦ CompleteBehavioral
How objects collaborate — assigning responsibilities and managing the flow of communication between them.
Pass a request along a chain of handlers until one of them handles it, decoupling sender from receiver.
✦ Complete 15 · Intermediate CommandTurn a request into a standalone object, letting you parameterize, queue, log, and undo operations.
✦ Complete 16 · Advanced InterpreterDefine a grammar for a simple language and an interpreter that evaluates sentences by walking an expression tree.
✦ Complete 17 · Beginner IteratorProvide a way to access the elements of a collection sequentially without exposing its underlying representation.
✦ Complete 18 · Intermediate MediatorCentralize communication between objects in a mediator, so they don't refer to each other directly.
✦ Complete 19 · Intermediate MementoCapture and externalize an object's internal state so it can be restored later — without violating its encapsulation.
✦ Complete 20 · Intermediate ObserverDefine a one-to-many dependency so that when one object changes state, all its dependents are notified automatically.
✦ Complete 21 · Intermediate StateLet an object alter its behavior when its internal state changes, as if it changed class.
✦ Complete 22 · Beginner StrategyDefine a family of interchangeable algorithms, encapsulate each one, and select which to use at runtime.
✦ Complete 23 · Intermediate Template MethodDefine the skeleton of an algorithm once, deferring the steps that vary to per-type implementations.
✦ Complete 24 · Advanced VisitorAdd new operations to a set of object types without modifying those types, by moving each operation into a visitor.
✦ CompleteGo Concurrency Patterns
The patterns that make Go special — goroutines and channels composed into pipelines, pools and safe cancellation.
Process a stream of data through a series of stages connected by channels, where each stage is a goroutine.
✦ Complete 26 · Intermediate Fan-out / Fan-inDistribute work across multiple goroutines (fan-out) and merge their results back into one stream (fan-in).
✦ Complete 27 · Beginner Worker PoolBound concurrency by feeding jobs to a fixed number of long-lived worker goroutines.
✦ Complete 28 · Beginner GeneratorProduce a stream of values from a goroutine over a channel, lazily and on demand.
✦ Complete 29 · Intermediate Or-done ChannelWrap a value stream so that ranging over it also stops cleanly the moment a cancellation signal fires.
✦ Complete 30 · Intermediate Context & CancellationPropagate cancellation, deadlines, and request-scoped values across API boundaries and goroutine trees with context.Context.
✦ Complete 31 · Intermediate SemaphoreLimit how many goroutines may run a section of code (or hold a resource) at the same time.
✦ Complete 32 · Intermediate errgroupRun a group of goroutines, wait for them all, capture the first error, and cancel the rest automatically.
✦ Complete 33 · Intermediate Pub/SubBroadcast events to many dynamic subscribers through a broker, decoupling producers from consumers.
✦ CompleteGo & the standard library
A tour of the classic design patterns hiding in plain sight across Go's standard library.
Tour PRACTICE · Reference Patterns Cheat-SheetA one-page map of every pattern — its intent, the idiomatic Go form, and when to reach for it. Built for revision and interview prep.
Revise🐹 A note on Go and patterns
Many “patterns” are really workarounds for things Java and C++ make hard. Go's interfaces, struct embedding, first-class functions and goroutines dissolve some of them and reshape the rest. Throughout this guide we'll call out when a pattern becomes a one-liner in Go — and when it's still genuinely useful.