You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 8, 2019. It is now read-only.
In an effort to keep errors.MultiErr immutable, we have the following for the Add method:
// Add adds an error returns a new MultiError object.
func (e MultiError) Add(err error) MultiError {
if err == nil {
return e
}
me := e
if me.err == nil {
me.err = err
return me
}
me.errors = append(me.errors, me.err)
me.err = err
return me
}
There's a couple of issues with this:
Almost every time someone unfamiliar with the API uses it, they mess up.
We never need to keep the original value around, so we always use this like: mulitErr = multiErr.Add(...)
We should just change the signature to make it apparent the method mutates the underlying struct: func (e *MultiError) Add(err error) { ... }
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
In an effort to keep
errors.MultiErr
immutable, we have the following for theAdd
method:There's a couple of issues with this:
mulitErr = multiErr.Add(...)
We should just change the signature to make it apparent the method mutates the underlying struct:
func (e *MultiError) Add(err error) { ... }
The text was updated successfully, but these errors were encountered: