# HG changeset patch # User Chris Jones # Date 1325464041 25200 # Node ID 82e90aa25dad730afea30d73ca9bb6ac85b2e8c5 # Parent f6bb47ca12f2ac5a098312cfc8a8e2716336796b Making a little more use of XMLName for marshaling instead of having a custom MarshalXML function. diff -r f6bb47ca12f2 -r 82e90aa25dad structs.go --- a/structs.go Sun Jan 01 17:22:48 2012 -0700 +++ b/structs.go Sun Jan 01 17:27:21 2012 -0700 @@ -153,12 +153,12 @@ // Describes an XMPP stanza error. See RFC 3920, Section 9.3. type Error struct { + XMLName xml.Name `xml:"error"` // The error type attribute. Type string `xml:"attr"` // Any nested element, if present. Any *Generic } -var _ xml.Marshaler = &Error{} var _ os.Error = &Error{} // Used for resource binding as a nested element inside . @@ -249,9 +249,6 @@ return buf.Bytes(), nil } -// BUG(cjyar) We can probably eliminate this if we use an -// appropriately-tagged XMLName field. - func (e *errText) MarshalXML() ([]byte, os.Error) { buf := bytes.NewBuffer(nil) buf.WriteString("") - if er.Any != nil { - xml.Marshal(buf, er.Any) - } - buf.WriteString("") - return buf.Bytes(), nil -} - -func (er *Error) String() string { - bytes, _ := er.MarshalXML() - return string(bytes) + xml.Marshal(buf, er) + return buf.String() } func (m *Message) GetName() string {