Instead of counting and using a done channel,
import "sync"
...
var wg sync.WaitGroup
for ... {
wg.Add(1)
go dowork()
}
wg.Wait()Instead of counting and using a done channel,
import "sync"
...
var wg sync.WaitGroup
for ... {
wg.Add(1)
go dowork()
}
wg.Wait()Since the standard libs in Go duplicate code, you would have to be careful that your suggestion system isn't picking up false positives. I think the idea has a lot of promise though.
Something like this would work even better:
result = src.asyncMap { |e| dowork(e) };
Except Google Go returns several values instead of tuples, so you can't just collect all the results as-is. And with no generics it would be annoying to actually use e and the result, since they would need casts. Too bad.> Except Google Go returns several values instead of tuples, so you can't just collect all the results as-is.
This is false. Functions in Go do not have to return multiple values. Therefore, you can "collect all the results as-is".
> And with no generics it would be annoying to actually use e and the result, since they would need casts. Too bad.
Actually, it wouldn't be annoying, because you wouldn't use a general purpose map like you've shown. You'd use code shown in the parent.