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

proposal: encoding/xml: Keep the annotation after do xml.Unmarshal #52174

Closed
CyberLife-Markus opened this issue Apr 6, 2022 · 1 comment
Closed

Comments

@CyberLife-Markus
Copy link

When the XML file is parsed by the Unmarshal function, restoring it using Marshal loses the original annotation content。

When dealing with some complex XML configuration files, the annotation information of corresponding fields is often very useful. Would you consider restoring the file annotation information during restoration?
example:

  • user.xml
<!-- Field content comment......-->
<user name="common">
.....
  • xml.go
	if err = xml.Unmarshal(userXMLFile, &user); err != nil {
		panic(err)
	}
	// Update of some field values...
	context, err := xml.Marshal(&user)
	if err != nil {
		panic(err)
	}
	// Output:
	// <!-- Field content comment......-->
	// <user name="new_username">
	// .....
@gopherbot gopherbot added this to the Proposal milestone Apr 6, 2022
@seankhliao
Copy link
Member

see the comment tag option

@golang golang locked and limited conversation to collaborators Apr 6, 2023
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

3 participants