From: Leigh McCulloch Date: Tue, 7 Nov 2017 05:33:35 +0000 (+0000) Subject: encoding/xml: add Marshal doc about name conflicts X-Git-Tag: go1.10beta1~350 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=65a864a628cb9ab767fb973d82ed979d6046f4f2;p=gostls13.git encoding/xml: add Marshal doc about name conflicts The docs for xml.Marshal state that the XML elements name is derived from one of five locations in a specific order of precedence, but does not mention that if the field is a struct type and has its name defined in a tag and in the types XMLName field that an error will occur. This is documented in the structFieldInfo function but not in the function documentation, and the existing docs in Marshal are misleading without this behavior being discussed. Fixes #18564 Change-Id: I29042f124a534bd1bc993f1baeddaa0af2e72fed Reviewed-on: https://go-review.googlesource.com/76321 Reviewed-by: Ian Lance Taylor --- diff --git a/src/encoding/xml/marshal.go b/src/encoding/xml/marshal.go index 42133a75ab..37b0dcb3c9 100644 --- a/src/encoding/xml/marshal.go +++ b/src/encoding/xml/marshal.go @@ -67,6 +67,9 @@ const ( // parent elements a and b. Fields that appear next to each other that name // the same parent will be enclosed in one XML element. // +// If the XML name for a struct field is defined by both the field tag and the +// struct's XMLName field, the names must match. +// // See MarshalIndent for an example. // // Marshal will return an error if asked to marshal a channel, function, or map.