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: different marshal behavior in the Go 1.21.6 #65066

Closed
picollomartin opened this issue Jan 11, 2024 · 1 comment
Closed

encoding/xml: different marshal behavior in the Go 1.21.6 #65066

picollomartin opened this issue Jan 11, 2024 · 1 comment

Comments

@picollomartin
Copy link

Go version

go version go1.21.6 darwin/amd64

Output of go env in your module/workspace:

N/A

What did you do?

package main

import (
	"encoding/xml"
	"fmt"
)

func main() {
	type B struct {
		XMLName xml.Name
		ID      string `xml:"id"`
	}

	type A struct {
		XMLName xml.Name `xml:"http://example.com a"`
		B       B        `xml:"b"`
	}

	output, err := xml.Marshal(&A{B: B{ID: "1"}})
	if err != nil {
		fmt.Println(err)
	}

	fmt.Printf("output: %s", string(output))
}

Playground example here

What did you see happen?

Output in go 1.21.6

output: <a xmlns="http://example.com"><b xmlns=""><id>1</id></b></a>

What did you expect to see?

Output in go 1.20

output: <a xmlns="http://example.com"><b><id>1</id></b></a>

It's similar to #61881, but this case it's like a bad use of XMLName tag, this break for us but can be fixed removing the XMLName tag not used, but previous versions simply ignored that

@seankhliao
Copy link
Member

Duplicate of #64166

@seankhliao seankhliao marked this as a duplicate of #64166 Jan 11, 2024
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants