-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
fmt: %#v of integer value in float64 (fraction = 0) incorrectly has ".0" suffix #27598
Comments
I think that commit was 7c7cecc. |
Oh, that would be it. So this is NOT a bug? |
Working as intended, now. If you use %#v you should get something that is recognizably a float. |
This is a significant irritation. I am wondering how to deal with testing the case that @dr2chase points to without having to duplicate the matrix formatting test code over the period where we are supporting Go versions that are before and after this change. |
@kortschak how many releases of Go do your code and tests support? It may be possible to skip the few tests that lock in this behavior on older versions of Go. Alternatively, is there no way to rewrite the tests to not lock in this particular behavior? For example, you could use a list of acceptable outputs, adding two entries for these cases. Or perhaps even use regular expressions, although that might make the test cases trickier to work with. |
We support current release plus the previous two. Skipping these tests without losing the whole formatting test suite would involve rewriting the tests significantly, and not locking in the behaviour loses us tests on behaviour that is tenuous anyway because of the unfriendliness of Using regexs for this is a horrible thing to have to do. It seems to me that the easiest way to deal with this is to just duplicate the test file and guard it with tag when that become possible (go1.12beta1 presumably). Until then we just see master tests as noise. |
But, WAI, not a bug. |
The behaviour that existed prior to 7c7cecc has been around since Go1 and I would have thought subject to the Go1 promise. Similar arguments have retained things like behaviour of sort order and PRNG sequence. Further, representing an integral float value without the decimal point is still valid Go syntax. Sure, you cannot correctly type infer from the output, but Go syntax formatting by fmt cannot be guaranteed to output a valid Go value anyway. |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?Tip.
go version devel +7a0eb56466 Fri Sep 7 17:28:27 2018 +0000 darwin/amd64
Does this issue reproduce with the latest release?
Not with 1.11, but with current Tip.
What operating system and processor architecture are you using (
go env
)?amd64, OSX
What did you do?
It's okay in the playground: https://play.golang.org/p/-tWXNCOTgVX
What did you expect to see?
What did you see instead?
I found this running the gonum tests. There it fails like so: (CC @btracey)
The text was updated successfully, but these errors were encountered: