-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove unwrapping in error Is
methods
#2269
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we're here, you could update Errors
to be Unwrap
that returns []error
. I don't think any call sites of Errors
use anything other than the Error
method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise LGTM!
d0f5c92
to
2ee34ab
Compare
out := make([]error, 0, len(errs)) | ||
for i := range errs { | ||
out = append(out, &errs[i]) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the alternative is to make errs
have type []error
, then type-assert everything in the sort.Slice
closure...
Hang on, does anything use the order of e.errs
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's nice for the user. I wrote tests for it, so they will break
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. Maybe I didn't 🤷♂️. Still think it's nice for the user.
I was doing some "light reading" of the go standard library, and noticed this:
In the former implementations, calling
errors.As
could unwrap the errors, so this PR fixes this.