An open API service indexing awesome lists of open source software.

https://github.com/beretta350/golang-design-patterns

This repository provides a comprehensive collection of design patterns implemented in Go (Golang). It serves as a practical guide to understanding and applying common software design patterns in real-world Golang projects.
https://github.com/beretta350/golang-design-patterns

adapter behavioralpatterns builder coding creationalpatterns designpatterns factory-pattern go golang observer-pattern programming singleton softwaredesign structuralpatterns

Last synced: 8 months ago
JSON representation

This repository provides a comprehensive collection of design patterns implemented in Go (Golang). It serves as a practical guide to understanding and applying common software design patterns in real-world Golang projects.

Awesome Lists containing this project

README

          

# Golang Design Patterns 🚀

Welcome to the **Golang Design Patterns** repository! This project is your ultimate reference guide for mastering design patterns in the Go programming language. Whether you're an experienced developer looking to sharpen your skills or a newcomer eager to learn, this repository provides practical examples and detailed explanations of commonly used design patterns.

## 🌟 What's Inside?

This repository includes Go implementations of various design patterns, categorized under:

1. **Creational Patterns**:
Patterns for creating objects in a way that suits the situation.
- [Factory](https://github.com/Beretta350/golang-design-patterns/tree/main/factory)
- [Builder](https://github.com/Beretta350/golang-design-patterns/tree/main/builder)
- [Singleton](https://github.com/Beretta350/golang-design-patterns/tree/main/singleton)
- ~~Prototype~~

2. **Structural Patterns**:
Patterns that help organize classes and objects in a manner that makes complex structures more manageable.
- [Adapter](https://github.com/Beretta350/golang-design-patterns/tree/main/adapter)
- ~~Composite~~
- ~~Proxy~~
- ~~Decorator~~

3. **Behavioral Patterns**:
Patterns that focus on effective communication between objects.
- [Observer](https://github.com/Beretta350/golang-design-patterns/tree/main/observer)
- ~~Strategy~~
- ~~Command~~
- ~~Chain of Responsibility~~

## 🧑‍💻 How to Use This Repository

Each pattern has its own directory containing:
- A clear, commented Go implementation.
- ~~A brief explanation of the pattern.~~
- ~~Examples of how to apply it in real-world scenarios.~~

### Clone the repository:

```bash
git clone https://github.com/Beretta350/golang-design-patterns.git
cd golang-design-patterns
```

### Run Examples

To run a specific design pattern example, navigate to the corresponding directory and **run the test file**. These tests demonstrate how the pattern works and highlight the benefits of each implementation.

For example, to see the **Factory Pattern** in action:

```bash
cd factory
go test
```

## 🚀 Why Design Patterns?

Design patterns are proven solutions to recurring problems in software design. By learning and implementing them, you’ll:
- Write **cleaner, more maintainable code**.
- Solve **complex design problems** with ease.
- Improve your **Go code structure** and **scalability**.

## 🤝 Contributing

Have an idea or improvement? Contributions are always welcome!
Feel free to:
- Submit a PR 🛠️
- Open an issue 🐞

### Guidelines:
1. Fork this repository.
2. Create a new branch for your feature/fix.
3. Submit a PR with a detailed description of your changes.

## 📖 Resources & Further Reading

- [Go Patterns](https://golang.org/doc/effective_go)
- [Design Patterns: Elements of Reusable Object-Oriented Software](https://en.wikipedia.org/wiki/Design_Patterns)
- [Refactoring Guru: Design patterns in Go](https://refactoring.guru/design-patterns/go)

## 💬 Contact

If you have any questions or just want to say hello, feel free to reach out via GitHub Issues or create a discussion thread!

---

**Happy Coding!** 🎉