Config Struct
A pattern for grouping related configuration options into a struct for cleaner function signatures.
A community-curated directory of idiomatic Go patterns. Find the pattern you need, see when to use it, and get back to coding.

Battle-tested patterns used in production by top Go developers worldwide.
Contributed and maintained by the Go community for the Go community.
Each pattern includes code examples, when to use, and when to avoid.
Recently submitted patterns from the community
A pattern for grouping related configuration options into a struct for cleaner function signatures.
A pattern for passing request-scoped values, cancellation signals, and deadlines through the call chain.
A pattern for adding context to errors while preserving the original error for inspection.
A pattern for clean, extensible API design using variadic functions for optional configuration.
A testing pattern that defines test cases as data in a table, enabling comprehensive and maintainable test coverage.
A concurrency pattern that limits parallelism by distributing work across a fixed number of goroutines.
Patterns with recent improvements and refinements
A pattern for grouping related configuration options into a struct for cleaner function signatures.
A pattern for passing request-scoped values, cancellation signals, and deadlines through the call chain.
A pattern for adding context to errors while preserving the original error for inspection.
A pattern for clean, extensible API design using variadic functions for optional configuration.
A testing pattern that defines test cases as data in a table, enabling comprehensive and maintainable test coverage.
A concurrency pattern that limits parallelism by distributing work across a fixed number of goroutines.
Contribute your Go patterns to help the community. Every pattern helps developers write better, more idiomatic Go code.
Contribute on GitHub