Go package implementing an error that can contain multiple errors
multierror
wraps multiple errors into a typed slice that implements Go's error
interface. It's useful
for iterators that don't bail when they encounter an error, but still need to return error information
to the caller.
multierror.MultiError
aims toward leanness and is mainly utilized with a combination of error
and
slice
semantics.
go get github.com/efixler/multierror
import (
"github.com/efixler/multierror"
)
func Worker() error {
merr := multierror.New()
for _, item := range work {
err := doSomething()
if err != nil {
merr = append(merr, err)
}
}
return merr.NilWhenEmpty()
}
See the Godoc for details and more examples.