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

x/xerrors: update with new %w semantics #33143

Open
zombiezen opened this issue Jul 17, 2019 · 5 comments
Assignees
Labels
Milestone

Comments

@zombiezen
Copy link
Contributor

@zombiezen zombiezen commented Jul 17, 2019

The launch decision on #29934 mentions changing fmt.Errorf to permit %w anywhere in the format string. golang.org/cl/176998 updated fmt at tip to support this, but xerrors.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?

err2: foo bar
err3: bar: foo

What did you see instead?

err2: %!w(*xerrors.errorString) bar
err3: bar: foo
@gopherbot gopherbot added this to the Unreleased milestone Jul 17, 2019
@carlmjohnson

This comment has been minimized.

Copy link
Contributor

@carlmjohnson carlmjohnson commented Jul 17, 2019

I ran into this myself. I tried to wrap with xerrors.Errorf("%w", err) and I was surprised when it didn't work. I debugged the wrong thing before changing it to ": %w".

@jba jba self-assigned this Jul 19, 2019
@jba

This comment has been minimized.

Copy link
Contributor

@jba jba commented Jul 19, 2019

I have a (clumsy, incomplete) fix for this at https://go-review.googlesource.com/c/xerrors/+/186957.

@sidh

This comment has been minimized.

Copy link

@sidh sidh commented Nov 15, 2019

Would really like to see a fix for this too.

Current behavior is wrong - https://play.golang.org/p/QncO3iOhWji

@sidh

This comment has been minimized.

Copy link

@sidh sidh commented Dec 2, 2019

Any news on this issue?

@jba

This comment has been minimized.

Copy link
Contributor

@jba jba commented Dec 4, 2019

I updated my CL to fix the problem @sidh pointed out. I'm waiting for a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.