Back to

Package multierror

Latest Go to latest
Published: Jun 24, 2020 | License: Apache-2.0 | Module:


Package Files

type MultiError

type MultiError struct {
	// contains filtered or unexported fields

MultiError is a mechanism for capturing errors from parallel go-routines. Usage:

errs := NewMultiError(3)
do := func(f foo) error {...}
for foo in range foos {
    go errs.capture(do(foo))
// Wait for completion

Will gather all errors returned in a MultiError, which in turn will behave as a normal error.

func NewMultiError

func NewMultiError(max int) *MultiError

NewMultiError creates a new MultiError struct.

func (*MultiError) Add

func (me *MultiError) Add(err error)

Add captures an error from a go-routine and adds it to the MultiError.

func (*MultiError) Err

func (me *MultiError) Err() error

Err returns an non-nil error representing all reported errors. Err returns nil when no errors where reported.

func (*MultiError) Error

func (me *MultiError) Error() string

Error returns a string version of the MultiError. This implements the error interface.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier