Hi all,
I wanted to follow up on CL 25242
(
https://go-review.googlesource.com/c/25242/) and ask the list about
expected behavior here. While implementing a fix for a panic in the
XML package when unmarshaling structs where the XMLName field was not
the first field (
https://github.com/golang/go/issues/16497) I ran into
what I think is behavior that goes against the intention.
When unmarshalling structs with embedded structs the anonymous fields
are counted as part of the outermost struct, however, because XMLName
fields of type xml.Name are handled specially, they are skipped by the
code that does this. This means that Marshal and Unmarshal are not
symetric functions, which feels wrong to me:
https://play.golang.org/p/_Fclhx4vmv
It's been this way for a while, so it may be set in stone, but I don't
think it's expected and XML package changes have been made in the past
where they were considered bugs and not part of the API contract (as I
think this is).
Thoughts? Is this actually the desired behavior of the package? There
is specifically a test for this, but the behavior doesn't make a lot
of sense to me.
—Sam
--
Sam Whited
pub 4096R/54083AE104EA7AD3