You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I upgraded to go1.2rc1 and previously working encoding/xml depended code broke.
Consider these 2 structs:
type SearchQuery struct {
XMLName string `xml:"search"`
Fields []interface{}
}
type TextField struct {
XMLName xml.Name
Is string `xml:"is,omitempty"`
IsNot string `xml:"is-not,omitempty"`
StartsWith string `xml:"starts-with,omitempty"`
EndsWidth string `xml:"ends-with,omitempty"`
Contains string `xml:"contains,omitempty"`
}
If SearchQuery contains e.g. TextField pointers, Marshal/Unmarshal fails with
xml: unsupported type: *package.TextField
If Fields contains plain structs (non-pointers), no error is returned.
The text was updated successfully, but these errors were encountered:
This test case passes in go1.1.2 and fails in go1.2rc1
package issue6556
import (
"encoding/xml"
"testing"
)
func TestStructPointerMarshal(t *testing.T) {
type A struct {
XMLName string `xml:"a"`
B []interface{}
}
type C struct {
XMLName xml.Name
Value string `xml:"value"`
}
a := new(A)
a.B = append(a.B, &C{
XMLName: xml.Name{Local: "c"},
Value: "x",
})
b, err := xml.Marshal(a)
if err != nil {
t.Fatal(err)
}
if x := string(b); x != "<a><c><value>x</value></c></a>" {
t.Fatal(x)
}
var v A
err = xml.Unmarshal(b, &v)
if err != nil {
t.Fatal(err)
}
}
The text was updated successfully, but these errors were encountered: