You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An important property implied by the documentation for %#v is that I can copy-paste the output into a Go program to recreate that value (at least for serializable values, e.g. not functions). At least, the function should be injective.
This is not true for numerics, since the output drops the dynamic type information. When I take the actual output above and put it in a new Go program, it gets assigned a different dynamic type:
package main
import "fmt"
import "reflect"
func main() {
n := 1.3167616e+07 // the output of `%#v`
fmt.Printf("%s\n", reflect.TypeOf(n).String())
}
which prints:
float64
This has cost me significant debugging time. The %#v verb should print out everything about the value that I need to know.
The text was updated successfully, but these errors were encountered:
You might be right, but regardless this isn't something we can change at this point. The Go 1 compatibility promise means we can't change the behavior of people's programs.
mikioh
changed the title
'%#v' verb does not print adequate dynamic type information for numerics
fmt: '%#v' verb does not print adequate dynamic type information for numerics
Jun 13, 2015
Steps to reproduce
Expected output
Actual output
Notes
An important property implied by the documentation for
%#v
is that I can copy-paste the output into a Go program to recreate that value (at least for serializable values, e.g. not functions). At least, the function should be injective.This is not true for numerics, since the output drops the dynamic type information. When I take the actual output above and put it in a new Go program, it gets assigned a different dynamic type:
which prints:
This has cost me significant debugging time. The
%#v
verb should print out everything about the value that I need to know.The text was updated successfully, but these errors were encountered: