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: unmarshaling empty xml val into non-zero struct has inconsistent behavior #19855
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
That's correct, documented behavior:
<Parent><Child><I>1</I></Child></Parent> would overwrite Parent.Child.I
I would rephrase your rule from:
That is, the general case is "walk further into the data structure" and it continues to work as before. It's the "treat empty string as zero" that is new, except that it's not. It's just a rule for interpreting data. This is split out in the 'go doc xml.Unmarshal' docs.
<Parent><Child><I>2</I></Child></Parent> writes 2 to Parent.Child.I.
This is the basic difference in the example in the report too: if the field is named, then a value is fetched for it and stored there. If not, it's not.