# senghoo/golang-design-pattern

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/senghoo-golang-design-pattern).**

9,027 stars · 2,087 forks · Go · MIT

## Links

- GitHub: https://github.com/senghoo/golang-design-pattern
- awesome-repositories: https://awesome-repositories.com/repository/senghoo-golang-design-pattern.md

## Description

This project is a collection of software design patterns implemented in Go, serving as a technical reference and a set of practical programming examples. It maps theoretical architectural patterns to concrete code to demonstrate structural, creational, and behavioral coding techniques.

The repository provides implementations for creational patterns focused on object instantiation and blueprint management, structural patterns for organizing object compositions, and behavioral patterns that manage object interactions and responsibilities. 

The content covers broad capability areas including interface design for decoupling abstractions from implementations, memory optimization through immutable state sharing, and the implementation of domain-specific language support via grammars and interpreters.

## Tags

### Software Engineering & Architecture

- [Design Pattern Implementations](https://awesome-repositories.com/f/software-engineering-architecture/design-pattern-implementations.md) — Provides a comprehensive collection of structural, creational, and behavioral design patterns implemented in Go.
- [Behavioral Design Patterns](https://awesome-repositories.com/f/software-engineering-architecture/behavioral-design-patterns.md) — Provides a comprehensive collection of behavioral design patterns managing object communication and responsibilities. ([source](https://github.com/senghoo/golang-design-pattern#readme))
- [Creational Design Patterns](https://awesome-repositories.com/f/software-engineering-architecture/creational-design-patterns.md) — Provides a comprehensive reference for creational design patterns and object instantiation mechanisms. ([source](https://github.com/senghoo/golang-design-pattern#readme))
- [Creational Patterns](https://awesome-repositories.com/f/software-engineering-architecture/dynamic-object-instantiation/object-lifecycle-management/creational-patterns.md) — Manages object creation and lifecycle using factories and prototypes to reduce system coupling.
- [Go API Architecture Design](https://awesome-repositories.com/f/software-engineering-architecture/go-api-architecture-design.md) — Applies Go-specific interface design principles to decouple abstractions from implementations.
- [Go Behavioral Patterns](https://awesome-repositories.com/f/software-engineering-architecture/go-behavioral-patterns.md) — Implements behavioral patterns such as observers and strategies to manage complex object interactions in Go.
- [Software Architecture Patterns](https://awesome-repositories.com/f/software-engineering-architecture/software-architecture-patterns.md) — Applies standard architectural patterns in Go to create maintainable and scalable software structures.
- [Structural Design Patterns](https://awesome-repositories.com/f/software-engineering-architecture/structural-design-patterns.md) — Provides a comprehensive set of structural design patterns including facades and adapters for object composition. ([source](https://github.com/senghoo/golang-design-pattern#readme))
- [Mediator Patterns](https://awesome-repositories.com/f/software-engineering-architecture/behavioral-design-patterns/mediator-patterns.md) — Implements mediator patterns using a central object to coordinate communication between components. ([source](https://github.com/senghoo/golang-design-pattern/tree/master/08_mediator))
- [Template Method Patterns](https://awesome-repositories.com/f/software-engineering-architecture/behavioral-design-patterns/template-method-patterns.md) — Implements template method patterns that define algorithm structures in base classes. ([source](https://github.com/senghoo/golang-design-pattern/tree/master/14_template_method))
- [Visitor Patterns](https://awesome-repositories.com/f/software-engineering-architecture/behavioral-design-patterns/visitor-patterns.md) — Provides visitor pattern implementations for separating algorithms from the objects they operate on. ([source](https://github.com/senghoo/golang-design-pattern/tree/master/23_visitor))
- [Chain of Responsibility Patterns](https://awesome-repositories.com/f/software-engineering-architecture/chain-of-responsibility-patterns.md) — Implements the chain of responsibility pattern to pass requests along a sequence of handlers. ([source](https://github.com/senghoo/golang-design-pattern/tree/master/21_chain_of_responsibility))
- [Command Pattern Implementations](https://awesome-repositories.com/f/software-engineering-architecture/command-pattern-implementations.md) — Implements the command pattern to wrap method calls into standalone objects for flexible execution. ([source](https://github.com/senghoo/golang-design-pattern/tree/master/11_command))
- [Factory Method Patterns](https://awesome-repositories.com/f/software-engineering-architecture/creational-design-patterns/factory-method-patterns.md) — Implements factory method patterns for delegating instantiation logic to dedicated factory objects. ([source](https://github.com/senghoo/golang-design-pattern/tree/master/04_factory_method))
- [Interface Instantiation Patterns](https://awesome-repositories.com/f/software-engineering-architecture/creational-design-patterns/factory-method-patterns/instantiation-pattern-migrations/interface-instantiation-patterns.md) — Demonstrates the use of dedicated constructor functions to instantiate and return interface implementations. ([source](https://github.com/senghoo/golang-design-pattern/tree/master/00_simple_factory))
- [Factory-Based Instantiation](https://awesome-repositories.com/f/software-engineering-architecture/dependency-injection-providers/factory-based-instantiation.md) — Provides mechanisms for object instantiation through factories to hide concrete implementation details from the client.
- [Adapter Patterns](https://awesome-repositories.com/f/software-engineering-architecture/interface-to-implementation-bindings/adapter-patterns.md) — Implements the Adapter pattern to translate interfaces into formats compatible with target interfaces. ([source](https://github.com/senghoo/golang-design-pattern/tree/master/02_adapter))
- [Composite Patterns](https://awesome-repositories.com/f/software-engineering-architecture/object-composition-patterns/composite-patterns.md) — Implements the Composite pattern to treat single objects and collections of objects under a shared interface. ([source](https://github.com/senghoo/golang-design-pattern/tree/master/13_composite))
- [Observer Pattern Implementations](https://awesome-repositories.com/f/software-engineering-architecture/observable-state-management/observer-pattern-implementations.md) — Implements the observer pattern to automatically notify dependent objects when a subject's state changes.
- [Reference Architectures](https://awesome-repositories.com/f/software-engineering-architecture/reference-architectures.md) — Serves as a technical reference mapping theoretical design patterns to concrete Go code.
- [Flyweight Patterns](https://awesome-repositories.com/f/software-engineering-architecture/shared-resource-objects/flyweight-patterns.md) — Reduces memory overhead by separating constant data from object instances using the Flyweight pattern. ([source](https://github.com/senghoo/golang-design-pattern/tree/master/18_flyweight))
- [Composition Over Inheritance](https://awesome-repositories.com/f/software-engineering-architecture/software-architecture/architectural-patterns/modular-decoupled-design/structural-design-paradigms/composition-over-inheritance.md) — Implements design approaches that favor building complex functionality by combining simple objects over deep inheritance hierarchies.
- [Strategy Pattern Implementations](https://awesome-repositories.com/f/software-engineering-architecture/strategy-pattern-implementations.md) — Provides an implementation of the strategy pattern to encapsulate and switch algorithms at runtime.
- [Facade Patterns](https://awesome-repositories.com/f/software-engineering-architecture/subsystem-registries/facade-patterns.md) — Implements the Facade pattern to provide a unified and simplified interface to complex subsystems. ([source](https://github.com/senghoo/golang-design-pattern/tree/master/01_facade))
- [Visitor Patterns](https://awesome-repositories.com/f/software-engineering-architecture/visitor-patterns.md) — Implements visitor patterns that decouple operations from the object structures they operate on.

### DevOps & Infrastructure

- [Interface-Based Decoupling](https://awesome-repositories.com/f/devops-infrastructure/dependency-management/dependency-injection-containers/package-dependency-decoupling/interface-based-decoupling.md) — Demonstrates how to program to interfaces to separate high-level logic from concrete implementations. ([source](https://github.com/senghoo/golang-design-pattern/tree/master/22_bridge))

### Education & Learning Resources

- [Go Design Pattern Examples](https://awesome-repositories.com/f/education-learning-resources/go-design-pattern-examples.md) — Offers practical code samples showing the implementation of industry-standard architectural patterns within the Go ecosystem.
- [Flyweight Implementations](https://awesome-repositories.com/f/education-learning-resources/structural-patterns/flyweights/flyweight-implementations.md) — Implements the flyweight pattern to reduce memory usage by sharing immutable state across similar objects.

### Artificial Intelligence & ML

- [Decorator Patterns](https://awesome-repositories.com/f/artificial-intelligence-ml/dynamic-class-extensions/decorator-patterns.md) — Implements the Decorator pattern to add functionality to objects dynamically by wrapping them. ([source](https://github.com/senghoo/golang-design-pattern/tree/master/20_decorator))

### Programming Languages & Runtimes

- [Go Memory Optimization](https://awesome-repositories.com/f/programming-languages-runtimes/memory-allocation-optimizations/go-memory-optimization.md) — Optimizes memory usage in Go by implementing the Flyweight pattern for immutable state sharing.
- [Object Cloning Patterns](https://awesome-repositories.com/f/programming-languages-runtimes/object-cloning-techniques/object-cloning-patterns.md) — Implements the Prototype pattern to create new object instances by copying existing ones. ([source](https://github.com/senghoo/golang-design-pattern/tree/master/07_prototype))
- [Abstract Factories](https://awesome-repositories.com/f/programming-languages-runtimes/object-creation-strategies/abstract-factories.md) — Implements the Abstract Factory pattern to ensure compatible groups of related objects are created. ([source](https://github.com/senghoo/golang-design-pattern/tree/master/05_abstract_factory))
- [Proxy Patterns](https://awesome-repositories.com/f/programming-languages-runtimes/promise-based-object-proxies/remote-object-proxies/proxy-patterns.md) — Implements the Proxy pattern to manage lazy initialization and handle remote communication via surrogate objects. ([source](https://github.com/senghoo/golang-design-pattern/tree/master/09_proxy))

### Web Development

- [Observer-Based Trigger Implementations](https://awesome-repositories.com/f/web-development/web-components/component-based-rendering-engines/observation-based-rendering/observer-based-trigger-implementations.md) — Implements automated notification of dependent objects when a primary object's state changes. ([source](https://github.com/senghoo/golang-design-pattern/tree/master/10_observer))

### Part of an Awesome List

- [Design Patterns](https://awesome-repositories.com/f/awesome-lists/learning/design-patterns.md) — Demonstrates structural and behavioral patterns using idiomatic code.
