-
Notifications
You must be signed in to change notification settings - Fork 18k
x/xerrors: update with new %w semantics #33143
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
Comments
I ran into this myself. I tried to wrap with |
I have a (clumsy, incomplete) fix for this at https://go-review.googlesource.com/c/xerrors/+/186957. |
Would really like to see a fix for this too. Current behavior is wrong - https://play.golang.org/p/QncO3iOhWji |
Any news on this issue? |
I updated my CL to fix the problem @sidh pointed out. I'm waiting for a review. |
Another issue which actually has a TODO in the code - https://play.golang.org/p/KJZ0Uirj48r |
(First, that CL was submitted, but for some reason this bug wasn't closed. I guess that's a blessing in disguise :) @sidh, there are several such problems that would require better parsing of the format string. However, since Go 1.14 is coming out shortly and it will make xerrors obsolete, I don't think it's worth fixing them. |
To clarify: once 1.14 is out, the only two officially supported versions of Go are 1.13 and 1.14, both of which have the new errors support. So if you follow the official policy, you can remove xerrors from your code. |
Yeah, I've updated our version already. Problem with switching to stdlib version of errors is you will miss out on stack frames and neat formatting. May be there is another package out there, all compatible with 1.13 errors? I'd prefer not to write it myself if there is one. |
Fixed in CL 186957. |
The launch decision on #29934 mentions changing
fmt.Errorf
to permit%w
anywhere in the format string. golang.org/cl/176998 updatedfmt
at tip to support this, butxerrors.Errorf
has not been given the new semantics yet. Since xerrors will presumably be used as a transition package for folks writing libraries that need to support older versions of Go, I think it's still worth updating xerrors to include this behavior.@jba @neild
What did you do?
https://play.golang.org/p/rL3z0G4cmnR
What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: