We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
go version
1.21.4
Yes
go env
windows/amd64
Consider following code snippet:
func main() { type B struct { XMLName xml.Name C bool `xml:"c"` } type A struct { XMLName xml.Name `xml:"http://example.com a"` B B } a := A{ B: B{ C: true, }, } output, err := xml.Marshal(&a) if err != nil { fmt.Println(err) } fmt.Printf("output: %s", string(output)) }
output: <a xmlns="http://example.com"><B><c>true</c></B></a>
output: <a xmlns="http://example.com"><B xmlns=""><c>true</c></B></a>
This issue seems related to #61881 If one adds a tag to the XMLName field in B
type B struct { XMLName xml.Name `xml:"b"` C bool `xml:"c"` }
then the empty namespace does not show up in the marshall result (in 1.21.1+).
The text was updated successfully, but these errors were encountered:
I believe this is working as intended. The order of precedence we have is:
and #7113 / CL 108796 requires the enforcement of xmlns values from xml.Name
Sorry, something went wrong.
No branches or pull requests
What version of Go are you using (
go version
)?1.21.4
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?windows/amd64
What did you do?
Consider following code snippet:
Output in go 1.20.X
output: <a xmlns="http://example.com"><B><c>true</c></B></a>
Output in go 1.21+ (including 1.21.4)
output: <a xmlns="http://example.com"><B xmlns=""><c>true</c></B></a>
Remarks
This issue seems related to #61881 If one adds a tag to the XMLName field in B
then the empty namespace does not show up in the marshall result (in 1.21.1+).
The text was updated successfully, but these errors were encountered: