Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding/xml: Marshal ignores fields tagged with ",any" #3559

Closed
gopherbot opened this issue Apr 22, 2012 · 5 comments
Closed

encoding/xml: Marshal ignores fields tagged with ",any" #3559

gopherbot opened this issue Apr 22, 2012 · 5 comments
Milestone

Comments

@gopherbot
Copy link

by chris.jones.yar:

What steps will reproduce the problem?
http://play.golang.org/p/t897gzvOxP

What is the expected output?
<inner></inner>
<outer><inner></inner></outer>

What do you see instead?
<inner></inner>
<outer></outer>

Which compiler are you using (5g, 6g, 8g, gccgo)?
go test

Which operating system are you using?
Windows 7, 32bit

Which version are you using?  (run 'go version')
go version go1

Please provide any additional information below.
The "Any" field is tagged ",any" for the benefit of Unmarshal -- I
expect the tag (but not the entire field) to be ignored by Marshal.
@anacrolix
Copy link
Contributor

Comment 1:

I've attached a patch. However it fails the adjusted test:
-       ExpectXML:  
`<a><nested><value>known</value></nested></a>`,
+       ExpectXML:  
`<a><nested><value>known</value></nested><AnyField><unknown/></AnyField></a>`,
Some strange things going on with the parent nesting, I wouldn't have expected this from
reading the code.

Attachments:

  1. sux.patch (935 bytes)

@kylelemons
Copy link
Contributor

Comment 2:

Attached is a patch that includes the test, too.  I couldn't find any documentation that
seemed relevant to update, but this seems to have been deliberately omitted, so there
may be a pitfall somewhere that we should mention.
Another example of code that seems like it should work:
http://play.golang.org/p/3RGBUECm7z

Attachments:

  1. xmlany.patch (1391 bytes)

@rsc
Copy link
Contributor

rsc commented Sep 12, 2012

Comment 3:

Labels changed: added priority-later, removed priority-triage.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Sep 12, 2012

Comment 4:

Labels changed: added go1.1maybe.

@rsc
Copy link
Contributor

rsc commented Dec 22, 2012

Comment 5:

This issue was closed by revision a9121a1.

Status changed to Fixed.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1maybe label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants