fmt: %#v doesn't print type name for built-in underlying types #24815
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?go version go1.10.1 darwin/amd64
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?What did you do?
https://play.golang.org/p/A22cqb47FB9
What did you expect to see?
(main.Chan)(0x1043a080) (main.Func)(0xd5960) main.Int(1) main.Map{1:1} main.Slice{1} main.Struct{X:1}
Note the
main.Int(1)
part.What did you see instead?
(main.Chan)(0x1043a080) (main.Func)(0xd5960) 1 main.Map{1:1} main.Slice{1} main.Struct{X:1}
Note the
1
part.The type name isn't shown for Int like it is for the composite types like Slice and Map. This can make it difficult to understand the values in a composite type whose nested type(s) is an interface. For example, if the below code prints
[]Syntax{"a", "b"}
, the types of the slice values are ambiguous:This seems to violate the point of the
%#v
format:because the "Go-syntax representation of the value" is invalid:
Maybe this can at least be changed for Go v2?
The text was updated successfully, but these errors were encountered: