design-pattern-golang

module
v0.0.0-...-0a00fa3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 17, 2025 License: MIT

README ΒΆ

Go Design Patterns

Go Reference Go Report Card

This repository documents the implementation of common Software Design Patterns in the Go programming language. Each pattern includes:

  • πŸ› οΈ Go implementation
  • πŸ“˜ Use cases

πŸ“ Pattern Categories

πŸ”¨ Creational Patterns

These patterns provide object creation mechanisms that increase flexibility and reuse of existing code.

Pattern Description
Singleton Ensures a class has only one instance and provides a global point of access to it.
Factory Provides an interface for creating objects but lets subclasses alter the type.
Builder Constructs complex objects step by step.
Prototype Clones existing objects without depending on their classes.

πŸ—οΈ Structural Patterns

These patterns explain how to assemble objects and classes into larger structures.

Pattern Description
Adapter Converts the interface of a class into another interface clients expect.
Decorator Adds behavior to an object dynamically without affecting others.
Proxy Provides a surrogate or placeholder for another object.
Facade Provides a unified interface to a set of interfaces in a subsystem.

πŸ” Behavioral Patterns

These patterns are concerned with communication between objects.

Pattern Description
Strategy Defines a family of algorithms and makes them interchangeable.
Observer Lets objects notify other objects about changes in state.
Command Encapsulates a request as an object.
Chain of Responsibility Passes a request along a chain of handlers.

πŸ§ͺ Running the Examples

go test ./...

πŸ“š Resources Used

  • Head First Design Patterns
  • Design Patterns: Elements of Reusable Object-Oriented Software (Gang of Four)
  • Official Go Documentation

πŸ—οΈ Contribution Feel free to fork the repo and add more examples or improvements. Contributions are welcome!

git clone https://github.com/your-username/go-design-patterns.git
cd go-design-patterns

Directories ΒΆ

Path Synopsis
Package adapterpattern implements the Adapter Design Pattern that allows incompatible interfaces to work together by converting the interface of one type into another that client expects.
Package adapterpattern implements the Adapter Design Pattern that allows incompatible interfaces to work together by converting the interface of one type into another that client expects.
Package solid demonstrates the Single Responsibility Principle (SRP)
Package solid demonstrates the Single Responsibility Principle (SRP)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL