在Go中封送XML时如何保留标签的名称空间url

When I unmarshal and marshal this XML the URL for the namespace disappear:

<root xmlns:urn="http://test.example.com">
    <urn:copyright>tekst</urn:copyright>
</root>

Becomes:

<root xmlns:urn="">
    <urn:copyright></urn:copyright>
</root>

The code:

package main

import (
    "encoding/xml"
    "fmt"
)

type Root struct {
    XMLName      xml.Name     `xml:"root"`
    XmlNS        string       `xml:"xmlns:urn,attr"`
    Copyright    Copyright    `xml:"urn:copyright,omitempty"`
}

type Copyright struct {
    Text string `xml:",chardata"`
}

func main() {
    root := Root{}

    x := `<root xmlns:urn="http://test.example.com">
               <urn:copyright>text</urn:copyright>
          </root>`
    _ = xml.Unmarshal([]byte(x), &root)
    b, _ := xml.MarshalIndent(root, "", "    ")
    fmt.Println(string(b))
}

https://play.golang.org/p/1jSURtWuZO

Root.XmlNS isn't unmarshalled.

"The prefix xmlns is used only to declare namespace bindings and is by definition bound to the namespace name http://www.w3.org/2000/xmlns/." https://www.w3.org/TR/REC-xml-names/

According to both the XML specification and the Go unmarshaling rules xml:"http://www.w3.org/2000/xmlns/ urn,attr" should work yet it doesn't. I don't think the maintainers will like the marshalling complexity that follows.

You probably want to do the following.

    type Root struct {
        XMLName      xml.Name     `xml:"root"`
        Copyright    Copyright    `xml:"http://test.example.com copyright"`
    }