Use name tags for roster data structures.
--- a/roster.go Sat Dec 31 11:39:23 2011 -0700
+++ b/roster.go Sat Dec 31 11:45:44 2011 -0700
@@ -14,15 +14,13 @@
// Roster query/result
type RosterQuery struct {
- // Should always be NsRoster, "query"
- XMLName xml.Name
+ XMLName xml.Name `xml:"jabber:iq:roster query"`
Item []RosterItem
}
// See RFC 3921, Section 7.1.
type RosterItem struct {
- // Should always be "item"
- XMLName xml.Name
+ XMLName xml.Name `xml:"item"`
Jid string `xml:"attr"`
Subscription string `xml:"attr"`
Name string `xml:"attr"`
@@ -38,8 +36,7 @@
// that information.
func (cl *Client) fetchRoster() os.Error {
iq := &Iq{From: cl.Jid.String(), Id: <- cl.Id, Type: "get",
- Nested: RosterQuery{XMLName: xml.Name{Local: "query",
- Space: NsRoster}}}
+ Nested: RosterQuery{}}
ch := make(chan os.Error)
f := func(st Stanza) bool {
if iq.Type == "error" {
--- a/roster_test.go Sat Dec 31 11:39:23 2011 -0700
+++ b/roster_test.go Sat Dec 31 11:45:44 2011 -0700
@@ -14,9 +14,7 @@
// This is mostly just tests of the roster data structures.
func TestRosterIqMarshal(t *testing.T) {
- iq := &Iq{From: "from", Lang: "en", Nested:
- RosterQuery{XMLName: xml.Name{Space: NsRoster, Local:
- "query"}, Item: []RosterItem{}}}
+ iq := &Iq{From: "from", Lang: "en", Nested: RosterQuery{}}
exp := `<iq from="from" xml:lang="en"><query xmlns="` +
NsRoster + `"></query></iq>`
assertMarshal(t, exp, iq)