Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
encoding/xml: handling of anonymous pointer fields is broken #27240
This happens on both Go 1.10.4 and
This playground link shows what
As one can see, they're simply skipped.
The XML package tries to print the zero values instead. Which seems fine in theory, but here's the first weird behavior - as you can see via the print statements, the encoded value has been modified in-place.
But here's an even worse problem - if the encoded value isn't addressable, encoding panics via reflect: https://play.golang.org/p/7ORK8Vw8o6Q
I think these two problems need to be fixed. I see two possibilities:
I personally strongly prefer option 1, as that would make
The only problem with option 1 is that this may break some existing programs, in which case option 2 may be better in Go 1.x. Although it would still be possible to achieve the existing behavior, if
Whatever we settle for, the fix should be pretty simple - happy to put in the work.
This is how I read the docs anyways and seems sane to me. It also makes the package more internally consistent: when the children of an anonymous field are promoted they're still behind a pointer so