-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
errors: inconsistency between os.IsNotExist and errors.Is with wrapped error #38198
Comments
For better or worse, we chose not to change the definition of |
Thank you. Does it mean the we should always use |
You should use |
Would it be helpful to update the os.IsNotExist documentation to ensure that users end up using errors.Is() instead of os.IsNotExist when applicable? |
@harshavardhana That has been done for the future 1.16 release for #41122 in https://golang.org/cl/268897. There is nothing to do here, so closing this issue. Please comment if you disagree. |
This looks good @ianlancetaylor - thank you |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Playground
What did you expect to see?
Consistent reporting in both
errors.Is
andos.IsNotExist
with both wrapped and not wrappedno such file or directory
error.What did you see instead?
The original error returned by
ioutil.ReadFile
is recognized asErrNotExist
by botherrors.Is
andos.IsNotExist
.Error wrapped with
fmt.Errorf("text: %w", err)
is no longer recognized byos.IsNotExist
, but still recognized byerrors.Is
.The text was updated successfully, but these errors were encountered: