Closed buth closed 3 years ago
At the moment, Append never returns nil. The use case I've run across is the following, where a function returns an array of errors, and it's necessary to return an error if any of them are non-nil.
result, errs := multierrorFunc() if err := multierror.Append(nil, errs...); err != nil { return err }
I think all that would be needed is to add a check for the length of the error list and update this test.
if len(err.Errors) == 0 { return nil }
If this seems like non-breaking functionality that would be useful, I could submit a pull request.
Thanks all!
This is what the ErrorOrNil func is for: https://pkg.go.dev/github.com/hashicorp/go-multierror#Error.ErrorOrNil
ErrorOrNil
At the moment, Append never returns nil. The use case I've run across is the following, where a function returns an array of errors, and it's necessary to return an error if any of them are non-nil.
I think all that would be needed is to add a check for the length of the error list and update this test.
If this seems like non-breaking functionality that would be useful, I could submit a pull request.
Thanks all!