Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
encoding/xml: embedded struct with XMLName field not being ignored #10538
The embedded struct with field name XMLName of type xml.Name (with no tag) is being ignored.
issue #7614 fixed a similar problem when the embedded struct had a tag.
Here's the test:
The output I get is:
Both should give the same result, as the second line, with name as "svg" and a xmlns attribute also supplied.
changed the title
encoding/xml - embedded struct with XMLName field not being ignored
Jun 26, 2015
By laws of reflection, unexported fields are unreachable by .Value. Documentation mentions that reflect package is used. XMLName are allowed at any level of an inner struct but laws of
The "element" field above is not exported and no value can be obtained for the XMLName. This is the origin of the difference and is normal. This issue can cause panic is the cases documented for the reflect
The submitted fix checks that the assigned XMLName value can be obtained by the reflect package.