4 ms·
I'm not that experienced with Go, but it seems to me that the equivalent Go code to var foo = await bar(); is foo := bar() Go concurrency is much ni
by ceronman 6y ago
I'm not that experienced with Go, but it seems to me that the equivalent Go code to
var foo = await bar();
is
foo := bar()
Go concurrency is much nicer because it doesn't have colored functions. You can use the same functions and library both synchronously and concurrently in millions of goroutines.
- speedgoose 6y agoGolang's concurrency can be much more cumbersome in some cases. const foo = await Promise.all(randomArray.map(bar)); I would have to google stuff to know where to start for the golang version.
- hombre_fatal 6y agoSpoiler: 40 lines of wait group code in Go to implement that.
- tsimionescu 6y agoI don't think that's true. foo := bar() In Go is equivalent to auto foo = bar(); In C#, in terms of semantics. It is true that, due to the runtime implementation, go foo() Is significantly less wasteful than new Thread(() => foo()); So there is less of a need for async code in Go. But if you want to start multie things in parallel and await all of them, or if you want to create asynchronous workflows that modify shared resources without locking, you don't have any Go library or construct to help, which was precisely what async/await gives you.