camlistore has a syncutil package (godoc.org/camlistore.org/pkg/syncutil) that has similar features, albeit in different structures:
- Gate is used to limit the number of parallel workers
- Group is used where sync.WaitGroup would be used. The most important thing: you have access to the error that happened in your goroutines.
Here's how to use it:
var g = syncutil.NewGate(num_parallel_workers)
for _, job := range jobs {
wg.Go(func() error {
defer g.Done()
// do some long-running job
// the job may fail
return errJob
})
}
return wg.Err()
// You also have access to failing goroutines through wg.Errs()