From 418f3beebbe9ac34e46ac88aae63180500df5d0a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?O=C4=9Fuzhan=20Kazak?= <oguzhankazakk@gmail.com>
Date: Sun, 30 Apr 2023 14:09:10 +0300
Subject: [PATCH 1/2] Added "future_promise.md" file with an explanation of the
 future/promise pattern as reference.

---
 messaging/future_promise.md | 50 +++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 messaging/future_promise.md

diff --git a/messaging/future_promise.md b/messaging/future_promise.md
new file mode 100644
index 0000000..767f8aa
--- /dev/null
+++ b/messaging/future_promise.md
@@ -0,0 +1,50 @@
+# Future & Promise Pattern
+
+    Future pattern (also called Promise pattern) is a design pattern used in concurrent and asynchronous programming, which allows clients to start a potentially long-running operation and obtain its result in a non-blocking way by returning a placeholder object (a future or a promise).
+
+    When the operation completes, the result is set on the future/promise object, which can then be obtained by the client code through a blocking or non-blocking method call.
+
+### Types
+
+```go
+package main
+
+import (
+	"fmt"
+	"time"
+)
+
+type FutureInt struct {
+	ch chan int
+}
+```
+
+### Implementation
+
+```go
+func (f *FutureInt) Get() int {
+	return <-f.ch
+}
+
+func NewFutureInt() *FutureInt {
+	return &FutureInt{
+		ch: make(chan int),
+	}
+}
+
+func add(a, b int) *FutureInt {
+	f := NewFutureInt()
+	go func() {
+		time.Sleep(3 * time.Second) // Simulate long running task
+		f.ch <- a + b
+	}()
+	return f
+}
+
+func main() {
+	fmt.Println("Starting task...")
+	f := add(2, 3)
+	fmt.Println("Task started...")
+	fmt.Printf("Result: %d\n", f.Get())
+}
+```

From b273c11088754ce7dae4d83e35aec097d79c9625 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?O=C4=9Fuzhan=20Kazak?= <oguzhankazakk@gmail.com>
Date: Sun, 30 Apr 2023 14:11:30 +0300
Subject: [PATCH 2/2] "README.md" file future&promises section ticked.

---
 README.md | 136 +++++++++++++++++++++++++++---------------------------
 1 file changed, 68 insertions(+), 68 deletions(-)

diff --git a/README.md b/README.md
index 7d9f5f7..bcf46cc 100644
--- a/README.md
+++ b/README.md
@@ -13,98 +13,98 @@ A curated collection of idiomatic design & application patterns for Go language.
 
 ## Creational Patterns
 
-| Pattern | Description | Status |
-|:-------:|:----------- |:------:|
-| [Abstract Factory](/creational/abstract_factory.md) | Provides an interface for creating families of releated objects | ✘ |
-| [Builder](/creational/builder.md) | Builds a complex object using simple objects | ✔ |
-| [Factory Method](/creational/factory.md) | Defers instantiation of an object to a specialized function for creating instances | ✔ |
-| [Object Pool](/creational/object-pool.md) | Instantiates and maintains a group of objects instances of the same type | ✔ |
-| [Singleton](/creational/singleton.md) | Restricts instantiation of a type to one object | ✔ |
+|                     Pattern                     | Description                                                                        | Status |
+| :----------------------------------------------: | :--------------------------------------------------------------------------------- | :----: |
+| [Abstract Factory](/creational/abstract_factory.md) | Provides an interface for creating families of releated objects                    |   ✘   |
+|          [Builder](/creational/builder.md)          | Builds a complex object using simple objects                                       |   ✔   |
+|      [Factory Method](/creational/factory.md)      | Defers instantiation of an object to a specialized function for creating instances |   ✔   |
+|      [Object Pool](/creational/object-pool.md)      | Instantiates and maintains a group of objects instances of the same type           |   ✔   |
+|        [Singleton](/creational/singleton.md)        | Restricts instantiation of a type to one object                                    |   ✔   |
 
 ## Structural Patterns
 
-| Pattern | Description | Status |
-|:-------:|:----------- |:------:|
-| [Bridge](/structural/bridge.md) | Decouples an interface from its implementation so that the two can vary independently | ✘ |
-| [Composite](/structural/composite.md) | Encapsulates and provides access to a number of different objects | ✘ |
-| [Decorator](/structural/decorator.md) | Adds behavior to an object, statically or dynamically | ✔ |
-| [Facade](/structural/facade.md) | Uses one type as an API to a number of others | ✘ |
-| [Flyweight](/structural/flyweight.md) | Reuses existing instances of objects with similar/identical state to minimize resource usage | ✘ |
-| [Proxy](/structural/proxy.md) | Provides a surrogate for an object to control it's actions | ✔ |
+|              Pattern              | Description                                                                                  | Status |
+| :--------------------------------: | :------------------------------------------------------------------------------------------- | :----: |
+|    [Bridge](/structural/bridge.md)    | Decouples an interface from its implementation so that the two can vary independently        |   ✘   |
+| [Composite](/structural/composite.md) | Encapsulates and provides access to a number of different objects                            |   ✘   |
+| [Decorator](/structural/decorator.md) | Adds behavior to an object, statically or dynamically                                        |   ✔   |
+|    [Facade](/structural/facade.md)    | Uses one type as an API to a number of others                                                |   ✘   |
+| [Flyweight](/structural/flyweight.md) | Reuses existing instances of objects with similar/identical state to minimize resource usage |   ✘   |
+|     [Proxy](/structural/proxy.md)     | Provides a surrogate for an object to control it's actions                                   |   ✔   |
 
 ## Behavioral Patterns
 
-| Pattern | Description | Status |
-|:-------:|:----------- |:------:|
-| [Chain of Responsibility](/behavioral/chain_of_responsibility.md) | Avoids coupling a sender to receiver by giving more than object a chance to handle the request | ✘ |
-| [Command](/behavioral/command.md) | Bundles a command and arguments to call later | ✘ |
-| [Mediator](/behavioral/mediator.md) | Connects objects and acts as a proxy | ✘ |
-| [Memento](/behavioral/memento.md) | Generate an opaque token that can be used to go back to a previous state | ✘ |
-| [Observer](/behavioral/observer.md) | Provide a callback for notification of events/changes to data | ✔ |
-| [Registry](/behavioral/registry.md) | Keep track of all subclasses of a given class | ✘ |
-| [State](/behavioral/state.md) | Encapsulates varying behavior for the same object based on its internal state | ✘ |
-| [Strategy](/behavioral/strategy.md) | Enables an algorithm's behavior to be selected at runtime | ✔ |
-| [Template](/behavioral/template.md) | Defines a skeleton class which defers some methods to subclasses | ✘ |
-| [Visitor](/behavioral/visitor.md) | Separates an algorithm from an object on which it operates | ✘ |
+|                            Pattern                            | Description                                                                                    | Status |
+| :------------------------------------------------------------: | :--------------------------------------------------------------------------------------------- | :----: |
+| [Chain of Responsibility](/behavioral/chain_of_responsibility.md) | Avoids coupling a sender to receiver by giving more than object a chance to handle the request |   ✘   |
+|                 [Command](/behavioral/command.md)                 | Bundles a command and arguments to call later                                                  |   ✘   |
+|                [Mediator](/behavioral/mediator.md)                | Connects objects and acts as a proxy                                                           |   ✘   |
+|                 [Memento](/behavioral/memento.md)                 | Generate an opaque token that can be used to go back to a previous state                       |   ✘   |
+|                [Observer](/behavioral/observer.md)                | Provide a callback for notification of events/changes to data                                  |   ✔   |
+|                [Registry](/behavioral/registry.md)                | Keep track of all subclasses of a given class                                                  |   ✘   |
+|                   [State](/behavioral/state.md)                   | Encapsulates varying behavior for the same object based on its internal state                  |   ✘   |
+|                [Strategy](/behavioral/strategy.md)                | Enables an algorithm's behavior to be selected at runtime                                      |   ✔   |
+|                [Template](/behavioral/template.md)                | Defines a skeleton class which defers some methods to subclasses                               |   ✘   |
+|                 [Visitor](/behavioral/visitor.md)                 | Separates an algorithm from an object on which it operates                                     |   ✘   |
 
 ## Synchronization Patterns
 
-| Pattern | Description | Status |
-|:-------:|:----------- |:------:|
-| [Condition Variable](/synchronization/condition_variable.md) | Provides a mechanism for threads to temporarily give up access in order to wait for some condition | ✘ |
-| [Lock/Mutex](/synchronization/mutex.md) | Enforces mutual exclusion limit on a resource to gain exclusive access | ✘ |
-| [Monitor](/synchronization/monitor.md) | Combination of mutex and condition variable patterns | ✘ |
-| [Read-Write Lock](/synchronization/read_write_lock.md) | Allows parallel read access, but only exclusive access on write operations to a resource | ✘ |
-| [Semaphore](/synchronization/semaphore.md) | Allows controlling access to a common resource | ✔ |
+|                          Pattern                          | Description                                                                                        | Status |
+| :-------------------------------------------------------: | :------------------------------------------------------------------------------------------------- | :----: |
+| [Condition Variable](/synchronization/condition_variable.md) | Provides a mechanism for threads to temporarily give up access in order to wait for some condition |   ✘   |
+|           [Lock/Mutex](/synchronization/mutex.md)           | Enforces mutual exclusion limit on a resource to gain exclusive access                             |   ✘   |
+|            [Monitor](/synchronization/monitor.md)            | Combination of mutex and condition variable patterns                                               |   ✘   |
+|    [Read-Write Lock](/synchronization/read_write_lock.md)    | Allows parallel read access, but only exclusive access on write operations to a resource           |   ✘   |
+|          [Semaphore](/synchronization/semaphore.md)          | Allows controlling access to a common resource                                                     |   ✔   |
 
 ## Concurrency Patterns
 
-| Pattern | Description | Status |
-|:-------:|:----------- |:------:|
-| [N-Barrier](/concurrency/barrier.md) | Prevents a process from proceeding until all N processes reach to the barrier | ✘ |
-| [Bounded Parallelism](/concurrency/bounded_parallelism.md) | Completes large number of independent tasks with resource limits | ✔ |
-| [Broadcast](/concurrency/broadcast.md) | Transfers a message to all recipients simultaneously | ✘ |
-| [Coroutines](/concurrency/coroutine.md) | Subroutines that allow suspending and resuming execution at certain locations | ✘ |
-| [Generators](/concurrency/generator.md) | Yields a sequence of values one at a time | ✔ |
-| [Reactor](/concurrency/reactor.md) | Demultiplexes service requests delivered concurrently to a service handler and dispatches them syncronously to the associated request handlers | ✘ |
-| [Parallelism](/concurrency/parallelism.md) | Completes large number of independent tasks | ✔ |
-| [Producer Consumer](/concurrency/producer_consumer.md) | Separates tasks from task executions | ✘ |
+|                         Pattern                         | Description                                                                                                                                    | Status |
+| :-----------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------- | :----: |
+|            [N-Barrier](/concurrency/barrier.md)            | Prevents a process from proceeding until all N processes reach to the barrier                                                                  |   ✘   |
+| [Bounded Parallelism](/concurrency/bounded_parallelism.md) | Completes large number of independent tasks with resource limits                                                                               |   ✔   |
+|           [Broadcast](/concurrency/broadcast.md)           | Transfers a message to all recipients simultaneously                                                                                           |   ✘   |
+|          [Coroutines](/concurrency/coroutine.md)          | Subroutines that allow suspending and resuming execution at certain locations                                                                  |   ✘   |
+|          [Generators](/concurrency/generator.md)          | Yields a sequence of values one at a time                                                                                                      |   ✔   |
+|             [Reactor](/concurrency/reactor.md)             | Demultiplexes service requests delivered concurrently to a service handler and dispatches them syncronously to the associated request handlers |   ✘   |
+|         [Parallelism](/concurrency/parallelism.md)         | Completes large number of independent tasks                                                                                                    |   ✔   |
+|   [Producer Consumer](/concurrency/producer_consumer.md)   | Separates tasks from task executions                                                                                                           |   ✘   |
 
 ## Messaging Patterns
 
-| Pattern | Description | Status |
-|:-------:|:----------- |:------:|
-| [Fan-In](/messaging/fan_in.md) | Funnels tasks to a work sink (e.g. server) | ✔ |
-| [Fan-Out](/messaging/fan_out.md) | Distributes tasks among workers (e.g. producer) | ✔ |
-| [Futures & Promises](/messaging/futures_promises.md) | Acts as a place-holder of a result that is initially unknown for synchronization purposes | ✘ |
-| [Publish/Subscribe](/messaging/publish_subscribe.md) | Passes information to a collection of recipients who subscribed to a topic | ✔ |
-| [Push & Pull](/messaging/push_pull.md) | Distributes messages to multiple workers, arranged in a pipeline | ✘ |
+|                        Pattern                        | Description                                                                               | Status |
+| :---------------------------------------------------: | :---------------------------------------------------------------------------------------- | :----: |
+|              [Fan-In](/messaging/fan_in.md)              | Funnels tasks to a work sink (e.g. server)                                                |   ✔   |
+|             [Fan-Out](/messaging/fan_out.md)             | Distributes tasks among workers (e.g. producer)                                           |   ✔   |
+| [Futures &amp; Promises](/messaging/futures_promises.md) | Acts as a place-holder of a result that is initially unknown for synchronization purposes |   ✔   |
+|   [Publish/Subscribe](/messaging/publish_subscribe.md)   | Passes information to a collection of recipients who subscribed to a topic                |   ✔   |
+|        [Push &amp; Pull](/messaging/push_pull.md)        | Distributes messages to multiple workers, arranged in a pipeline                          |   ✘   |
 
 ## Stability Patterns
 
-| Pattern | Description | Status |
-|:-------:|:----------- |:------:|
-| [Bulkheads](/stability/bulkhead.md)  | Enforces a principle of failure containment (i.e. prevents cascading failures) | ✘ |
-| [Circuit-Breaker](/stability/circuit-breaker.md) | Stops the flow of the requests when requests are likely to fail | ✔ |
-| [Deadline](/stability/deadline.md) | Allows clients to stop waiting for a response once the probability of response becomes low (e.g. after waiting 10 seconds for a page refresh) | ✘ |
-| [Fail-Fast](/stability/fail_fast.md) | Checks the availability of required resources at the start of a request and fails if the requirements are not satisfied | ✘ |
-| [Handshaking](/stability/handshaking.md) | Asks a component if it can take any more load, if it can't, the request is declined | ✘ |
-| [Steady-State](/stability/steady_state.md) | For every service that accumulates a resource, some other service must recycle that resource | ✘ |
+|                    Pattern                    | Description                                                                                                                                   | Status |
+| :-------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------- | :----: |
+|       [Bulkheads](/stability/bulkhead.md)       | Enforces a principle of failure containment (i.e. prevents cascading failures)                                                                |   ✘   |
+| [Circuit-Breaker](/stability/circuit-breaker.md) | Stops the flow of the requests when requests are likely to fail                                                                               |   ✔   |
+|        [Deadline](/stability/deadline.md)        | Allows clients to stop waiting for a response once the probability of response becomes low (e.g. after waiting 10 seconds for a page refresh) |   ✘   |
+|       [Fail-Fast](/stability/fail_fast.md)       | Checks the availability of required resources at the start of a request and fails if the requirements are not satisfied                       |   ✘   |
+|     [Handshaking](/stability/handshaking.md)     | Asks a component if it can take any more load, if it can't, the request is declined                                                           |   ✘   |
+|    [Steady-State](/stability/steady_state.md)    | For every service that accumulates a resource, some other service must recycle that resource                                                  |   ✘   |
 
 ## Profiling Patterns
 
-| Pattern | Description | Status |
-|:-------:|:----------- |:------:|
-| [Timing Functions](/profiling/timing.md) | Wraps a function and logs the execution | ✔ |
+|                Pattern                | Description                             | Status |
+| :-----------------------------------: | :-------------------------------------- | :----: |
+| [Timing Functions](/profiling/timing.md) | Wraps a function and logs the execution |   ✔   |
 
 ## Idioms
 
-| Pattern | Description | Status |
-|:-------:|:----------- |:------:|
-| [Functional Options](/idiom/functional-options.md) | Allows creating clean APIs with sane defaults and idiomatic overrides | ✔ |
+|                     Pattern                     | Description                                                           | Status |
+| :---------------------------------------------: | :-------------------------------------------------------------------- | :----: |
+| [Functional Options](/idiom/functional-options.md) | Allows creating clean APIs with sane defaults and idiomatic overrides |   ✔   |
 
 ## Anti-Patterns
 
-| Pattern | Description | Status |
-|:-------:|:----------- |:------:|
-| [Cascading Failures](/anti-patterns/cascading_failures.md) | A failure in a system of interconnected parts in which the failure of a part causes a domino effect | ✘ |
+|                         Pattern                         | Description                                                                                         | Status |
+| :-----------------------------------------------------: | :-------------------------------------------------------------------------------------------------- | :----: |
+| [Cascading Failures](/anti-patterns/cascading_failures.md) | A failure in a system of interconnected parts in which the failure of a part causes a domino effect |   ✘   |