gogroup provides a group of goroutines used to run functions concurrently.
var g gogroup.Group
g.Add(func(ctx context.Context) error {
// do something
return nil
})
g.Add(func(ctx context.Context) error {
// convert panic as an error and cancel the context
panic("panic")
})
if err := g.Run(ctx); err != nil {
return err
}
MIT