2 ms·
An easy example of where having promises is nice: a := getFoo() b := getBar() c := getBaz() If you want to do all 3 in parallel, you may need to use cha
by phamilton 5y ago
An easy example of where having promises is nice:
a := getFoo()
b := getBar()
c := getBaz()
If you want to do all 3 in parallel, you may need to use channels and wait groups and stuff. In a language with promises:
const a = getFoo();
const b = getBar();
const c = getBaz();
await a
await b
await c
or even better
const [a,b,c] = await Promise.all([getFoo(), getBar(), getBaz()])
If/when go generics become available, I expect to see some libraries that make things easier in golang.