"Future & Promises" example added. by OguzhanKazak · Pull Request #119 · tmrts/go-patterns

@OguzhanKazak

Added "future_promise.md" file with an explanation of the future/promise pattern in concurrent and asynchronous programming, as part of a general pattern list for reference. The file describes the basic idea behind the pattern, its benefits, and its usage in different programming languages and frameworks.

…ise pattern as reference.

@abchahahah

package main

import "fmt"

func add(a, b int) <-chan int {
	res := make(chan int)
	go func() {
		res <- a + b
		close(res)
	}()
	return res
}

func main() {
	c := add(1, 2)
	fmt.Println(<-c)
}

I think it would be more common to use chan directly in go.