encoding/xml: allow embedded non-structs
The old code just assumed that the only thing
you can embed is a struct. Not true.
Fixes #3803.
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7743043
diff --git a/src/pkg/encoding/xml/marshal_test.go b/src/pkg/encoding/xml/marshal_test.go
index 3a190de..1373e01 100644
--- a/src/pkg/encoding/xml/marshal_test.go
+++ b/src/pkg/encoding/xml/marshal_test.go
@@ -266,6 +266,12 @@
V interface{}
}
+type MyInt int
+
+type EmbedInt struct {
+ MyInt
+}
+
// Unless explicitly stated as such (or *Plain), all of the
// tests below are two-way tests. When introducing new tests,
// please try to make them two-way as well to ensure that
@@ -790,6 +796,12 @@
},
UnmarshalOnly: true,
},
+ {
+ ExpectXML: `<EmbedInt><MyInt>42</MyInt></EmbedInt>`,
+ Value: &EmbedInt{
+ MyInt: 42,
+ },
+ },
}
func TestMarshal(t *testing.T) {