Documentation ¶
Overview ¶
Package multierrgroup provides a mix of multierr and errgroup See documentation for https://pkg.go.dev/go.uber.org/multierr and https://pkg.go.dev/golang.org/x/sync/errgroup
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group manages goroutines and collect all the errors. See https://pkg.go.dev/golang.org/x/sync/errgroup#Group for more information
Example ¶
package main import ( "errors" "fmt" "go.ptx.dk/multierrgroup" "go.uber.org/multierr" ) func main() { g := multierrgroup.Group{} g.Go(func() error { return errors.New("error 1") }) g.Go(func() error { return errors.New("error 2") }) err := g.Wait() // Using golang.org/x/sync/errgroup would return a return error depending on which goroutine was scheduled first errs := multierr.Errors(err) fmt.Println("Got", len(errs), "errors") }
Output: Got 2 errors
func WithContext ¶
WithContext returns a new Group with a associated Context. The context will be canceled if any goroutine returns an error. See https://pkg.go.dev/golang.org/x/sync/errgroup#WithContext
Click to show internal directories.
Click to hide internal directories.