3 ms·
This is a weird example as Promise.all and Promise.race are what are pretty easy to write in Go: Promise.all is trivial: return <-a, <-b, <-c Promise.rac
by morelisp 4y ago
This is a weird example as Promise.all and Promise.race are what are pretty easy to write in Go:
Promise.all is trivial:
return <-a, <-b, <-c
Promise.race is a little longer:
select {
case x := <-a: return x
case x := <-b: return x
case x := <-c: return x
}
What Go doesn't do very well compared to promises is composing; composing channels, especially with error returns, is usually tricky. But async/await are also bad at this. Passing around the actual promise/futures objects is the best way, which is for some reason discouraged today in favor of await/async noise in most cases.