|
|
|
|
|
by crawshaw
4221 days ago
|
|
Note that when designing servers at Google in Go, we strongly discourage the use of concepts like futures and promises. They exist as abstractions that work around heavyweight threads. In Go, you have lightweight threads which remove the need for futures. Create a new goroutine and block on the action. You can continue working in another goroutine and communicate between them using channels. The advantage of this programming model over futures/promises is straight-line code that is easier to read and reason about. For example, when bugs appear you get a nice stack trace that reveals the state of the call. Future leave you in a callback-like mess. See http://blog.golang.org/pipelines for more details. |
|
It seems to be because each goroutine has a single parent (which launched it), so there is typically a single reader for its return value.