Collections of Go patterns based on tmrts/go-patterns, But merged with other awesome forks and more improvoments. https://crazybber.github.io/awesome-patterns/
Go to file
2016-02-20 17:34:36 +02:00
bounded_parallelism Implement parallelism patterns 2016-02-20 17:33:41 +02:00
circuitbreaker Implement circuit-breaker design pattern 2016-02-20 17:33:21 +02:00
fan Add fan-in/out messaging patterns 2016-02-20 17:34:05 +02:00
parallelism Implement parallelism patterns 2016-02-20 17:33:41 +02:00
semaphore Update semaphore pattern 2016-02-20 17:32:46 +02:00
singleton Implement singleton pattern 2016-02-20 17:34:36 +02:00
strategy Modify strategy pattern 2016-02-20 17:32:02 +02:00
.gitignore Initial commit 2015-12-15 00:05:06 +02:00
CONTRIBUTING.md Update README and Contribution Guidelines 2015-12-23 15:51:06 +02:00
decorator.go Add decorator pattern 2015-12-23 15:46:27 +02:00
functional_options.go Include more patterns and a logo 2016-01-01 21:06:10 +02:00
gopher.jpg Include more patterns and a logo 2016-01-01 21:06:10 +02:00
LICENSE Initial commit 2015-12-15 00:05:06 +02:00
publish_subscribe.go Include more patterns and a logo 2016-01-01 21:06:10 +02:00
README.md Include more patterns and a logo 2016-01-01 21:06:10 +02:00

Go Patterns Travis Widget Awesome Widget License Widget

A curated collection of idiomatic design & application patterns for Go language.

Creational Patterns:

Pattern Description
Abstract Factory use a generic function with specific factories
Borg Singleton a singleton with shared-state among instances
Builder instead of using multiple constructors, builder object receives parameters and returns constructed objects
Factory Method delegate a specialized function/method to create instances
Lazy Evaluation lazily-evaluated property pattern in Go
Object Pool preinstantiate and maintain a group of instances of the same type
Prototype use a factory and clones of a prototype for new instances (if instantiation is expensive)

Structural Patterns:

Pattern Description
Adapter adapt one interface to another using a white-list
Bridge a client-provider middleman to soften interface changes
Composite encapsulate and provide access to a number of different objects
Decorator Adds behavior to an object, statically or dynamically
Facade use one class as an API to a number of others
Flyweight transparently reuse existing instances of objects with similar/identical state
Model View Controller model<->view<->controller (non-strict relationships)
Proxy an object funnels operations to something else

Behavioral Patterns:

Pattern Description
Chain apply a chain of successive handlers to try and process the data
Catalog general methods will call different specialized methods based on construction parameter
Chaining Method continue callback next object method
Command bundle a command and arguments to call later
Mediator an object that knows how to connect other objects and act as a proxy
Memento generate an opaque token that can be used to go back to a previous state
Observer provide a callback for notification of events/changes to data
Publish/Subscribe Passes information to a collection of recipients who subscribed to a topic
Registry keep track of all subclasses of a given class
Specification business rules can be recombined by chaining the business rules together using boolean logic
State logic is organized into a discrete number of potential states and the next state that can be transitioned to
Strategy Encapsulates an algorithm inside a struct
Template an object imposes a structure but takes pluggable components
Visitor invoke a callback for all items of a collection

Synchronization Patterns:

Pattern Description
Lock/Mutex Enforces mutual exclusion limit on accessing a resource
Read-Write Lock
Condition Variable
Monitor Combination of mutex and condition patterns
Semaphore Allows controlling access to a common resource

Concurrency Patterns:

Pattern Description
Scheduler
Barrier
Producer Consumer
Futures
Broadcast
Multiplex
Fan-In
Generators
Coroutines

Stability Patterns:

Pattern Description
Bulkheads
Circuit Breaker
Deadline
Fail Fast
Handshaking
Steady State

Profiling Patterns:

Pattern Description
Timing Functions Wraps a function and logs the execution

Idioms:

Pattern Description
Functional Options Allows creating clean APIs with sane defaults and idiomatic overrides

Anti-Patterns:

Pattern Description

Other Patterns:

Pattern Description

License

Creative Commons License

This work is licensed under a Creative Commons Attribution 4.0 International License.