Navigation Menu

Skip to content
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

proposal: strconv: NumError implementing Unwrap #36325

Closed
JOT85 opened this issue Dec 30, 2019 · 4 comments
Closed

proposal: strconv: NumError implementing Unwrap #36325

JOT85 opened this issue Dec 30, 2019 · 4 comments

Comments

@JOT85
Copy link

JOT85 commented Dec 30, 2019

The strconv.NumError struct (https://golang.org/pkg/strconv/#NumError) contains the error which caused the conversion to fail in the Err field. It seems like it would be nice for NumError to implement the Unwrap() error method so that, for example, errors.Is(err, strconv.ErrRange) could be used. By exposing the struct field it is already part of the API and implementing the Unwrap method is a more convenient and standard way to use it.

@gopherbot gopherbot added this to the Proposal milestone Dec 30, 2019
@ianlancetaylor
Copy link
Contributor

CC @jba @neild

@neild
Copy link
Contributor

neild commented Dec 30, 2019

SGTM. Pretty sure I just overlooked it when adding Unwrap methods in 1.13.

@JOT85
Copy link
Author

JOT85 commented Dec 30, 2019

I've just realised, this change was added in commit 0adc89a to master which hasn't yet been put in to a release. It's tagged for go1.14beta1. Sorry about that.

@smasher164
Copy link
Member

Closing since this is already in 1.14.

@golang golang locked and limited conversation to collaborators Dec 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants