3 ms·
Async/await is just a callback flattened into the function body. I.E. var x = await foo(); var y = await doStuffWith(x); return x + y; Is equival
by rspeele 4y ago
Async/await is just a callback flattened into the function body.
I.E.
var x = await foo();
var y = await doStuffWith(x);
return x + y;
Is equivalent to, in a less enlightened language...
foo().callback(x =>
doStuffWith(x).callback(y =>
x + y));
Goroutines are a more general feature in that channels can accept multiple inputs in sequence. But you can basically think of async/await as a special (the most commmon?) case of goroutines/channels, where the called goroutine sends back a single value on the channel as its one and only result.