# HG changeset patch # User Chris Jones # Date 1364316884 21600 # Node ID 5c6d6d51d3bafae596541d8cc600a8d737c72942 # Parent 7c45fc3f524a9b8aac53c5f9e6cea57fe80ee8d0 gofmt diff -r 7c45fc3f524a -r 5c6d6d51d3ba examples/interact.go --- a/examples/interact.go Fri Dec 28 17:56:13 2012 -0700 +++ b/examples/interact.go Tue Mar 26 10:54:44 2013 -0600 @@ -59,7 +59,7 @@ } roster := xmpp.Roster(c) fmt.Printf("%d roster entries:\n", len(roster)) - for i, entry := range(roster) { + for i, entry := range roster { fmt.Printf("%d: %v\n", i, entry) } @@ -85,7 +85,7 @@ } var se *xml.StartElement var ok bool - if se, ok = t.(*xml.StartElement) ; !ok { + if se, ok = t.(*xml.StartElement); !ok { fmt.Println("Couldn't find start element") break } diff -r 7c45fc3f524a -r 5c6d6d51d3ba log.go --- a/log.go Fri Dec 28 17:56:13 2012 -0700 +++ b/log.go Tue Mar 26 10:54:44 2013 -0600 @@ -10,8 +10,8 @@ // If any of these are non-nil when NewClient() is called, // they will be used to log messages of the indicated // severity. - Warn Logger = &noLog{} - Info Logger = &noLog{} + Warn Logger = &noLog{} + Info Logger = &noLog{} Debug Logger = &noLog{} ) @@ -27,6 +27,7 @@ flags int prefix string } + var _ Logger = &noLog{} func (l *noLog) Log(v ...interface{}) { diff -r 7c45fc3f524a -r 5c6d6d51d3ba roster.go --- a/roster.go Fri Dec 28 17:56:13 2012 -0700 +++ b/roster.go Tue Mar 26 10:54:44 2013 -0600 @@ -15,7 +15,7 @@ // Roster query/result type RosterQuery struct { - XMLName xml.Name `xml:"jabber:iq:roster query"` + XMLName xml.Name `xml:"jabber:iq:roster query"` Item []RosterItem `xml:"item"` } diff -r 7c45fc3f524a -r 5c6d6d51d3ba stream.go --- a/stream.go Fri Dec 28 17:56:13 2012 -0700 +++ b/stream.go Tue Mar 26 10:54:44 2013 -0600 @@ -79,8 +79,8 @@ } func readXml(r io.Reader, ch chan<- interface{}, -extStanza map[string]func(*xml.Name) interface{}) { - if _, ok := Debug.(*noLog) ; !ok { + extStanza map[string]func(*xml.Name) interface{}) { + if _, ok := Debug.(*noLog); !ok { pr, pw := io.Pipe() go tee(r, pw, "S: ") r = pr @@ -152,7 +152,7 @@ // If it's a Stanza, we try to unmarshal its innerxml // into objects of the appropriate respective // types. This is specified by our extensions. - if st, ok := obj.(Stanza) ; ok { + if st, ok := obj.(Stanza); ok { err = parseExtended(st.GetHeader(), extStanza) if err != nil { Warn.Logf("ext unmarshal: %s", err) @@ -198,7 +198,7 @@ } func writeXml(w io.Writer, ch <-chan interface{}) { - if _, ok := Debug.(*noLog) ; !ok { + if _, ok := Debug.(*noLog); !ok { pr, pw := io.Pipe() go tee(pr, w, "C: ") w = pw @@ -274,7 +274,7 @@ // with the server. The control channel controls this loop's // activity. func writeStream(srvOut chan<- interface{}, cliIn <-chan Stanza, -control <-chan int) { + control <-chan int) { defer close(srvOut) var input <-chan Stanza @@ -306,7 +306,7 @@ // Stanzas from the remote go up through a stack of filters to the // app. This function manages the filters. func filterTop(filterOut <-chan <-chan Stanza, filterIn chan<- <-chan Stanza, -topFilter <-chan Stanza, app chan<- Stanza) { + topFilter <-chan Stanza, app chan<- Stanza) { defer close(app) Loop: for { @@ -563,7 +563,7 @@ // Computes the response string for digest authentication. func saslDigestResponse(username, realm, passwd, nonce, cnonceStr, -authenticate, digestUri, nonceCountStr string) string { + authenticate, digestUri, nonceCountStr string) string { h := func(text string) []byte { h := md5.New() h.Write([]byte(text)) diff -r 7c45fc3f524a -r 5c6d6d51d3ba structs.go --- a/structs.go Fri Dec 28 17:56:13 2012 -0700 +++ b/structs.go Tue Mar 26 10:54:44 2013 -0600 @@ -38,19 +38,20 @@ Lang string `xml:"http://www.w3.org/XML/1998/namespace lang,attr"` Version string `xml:"version,attr"` } + var _ fmt.Stringer = &stream{} // type streamError struct { XMLName xml.Name `xml:"http://etherx.jabber.org/streams error"` - Any Generic `xml:",any"` - Text *errText + Any Generic `xml:",any"` + Text *errText } type errText struct { XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams text"` Lang string `xml:"http://www.w3.org/XML/1998/namespace lang,attr"` - Text string `xml:",chardata"` + Text string `xml:",chardata"` } type Features struct { @@ -84,41 +85,44 @@ // One of the three core XMPP stanza types: iq, message, presence. See // RFC3920, section 9. type Header struct { - To string `xml:"to,attr,omitempty"` - From string `xml:"from,attr,omitempty"` - Id string `xml:"id,attr,omitempty"` - Type string `xml:"type,attr,omitempty"` - Lang string `xml:"http://www.w3.org/XML/1998/namespace lang,attr,omitempty"` - Innerxml string `xml:",innerxml"` + To string `xml:"to,attr,omitempty"` + From string `xml:"from,attr,omitempty"` + Id string `xml:"id,attr,omitempty"` + Type string `xml:"type,attr,omitempty"` + Lang string `xml:"http://www.w3.org/XML/1998/namespace lang,attr,omitempty"` + Innerxml string `xml:",innerxml"` Error *Error Nested []interface{} } // message stanza type Message struct { - XMLName xml.Name `xml:"jabber:client message"` + XMLName xml.Name `xml:"jabber:client message"` Header - Subject *Generic `xml:"jabber:client subject"` - Body *Generic `xml:"jabber:client body"` - Thread *Generic `xml:"jabber:client thread"` + Subject *Generic `xml:"jabber:client subject"` + Body *Generic `xml:"jabber:client body"` + Thread *Generic `xml:"jabber:client thread"` } + var _ Stanza = &Message{} // presence stanza type Presence struct { - XMLName xml.Name `xml:"presence"` + XMLName xml.Name `xml:"presence"` Header Show *Generic `xml:"jabber:client show"` Status *Generic `xml:"jabber:client status"` Priority *Generic `xml:"jabber:client priority"` } + var _ Stanza = &Presence{} // iq stanza type Iq struct { - XMLName xml.Name `xml:"iq"` + XMLName xml.Name `xml:"iq"` Header } + var _ Stanza = &Iq{} // Describes an XMPP stanza error. See RFC 3920, Section 9.3. @@ -129,6 +133,7 @@ // Any nested element, if present. Any *Generic } + var _ error = &Error{} // Used for resource binding as a nested element inside . @@ -142,8 +147,9 @@ type Generic struct { XMLName xml.Name Any *Generic `xml:",any"` - Chardata string `xml:",chardata"` + Chardata string `xml:",chardata"` } + var _ fmt.Stringer = &Generic{} func (jid *JID) String() string { diff -r 7c45fc3f524a -r 5c6d6d51d3ba structs_test.go --- a/structs_test.go Fri Dec 28 17:56:13 2012 -0700 +++ b/structs_test.go Tue Mar 26 10:54:44 2013 -0600 @@ -125,7 +125,7 @@ go readXml(r, ch, make(map[string]func(*xml.Name) interface{})) obs := <-ch exp := &Message{XMLName: xml.Name{Local: "message", Space: "jabber:client"}, - Header: Header{To:"a@b.c", Innerxml: "foo!"}, + Header: Header{To: "a@b.c", Innerxml: "foo!"}, Body: &Generic{XMLName: xml.Name{Local: "body", Space: "jabber:client"}, Chardata: "foo!"}} if !reflect.DeepEqual(obs, exp) { diff -r 7c45fc3f524a -r 5c6d6d51d3ba xmpp.go --- a/xmpp.go Fri Dec 28 17:56:13 2012 -0700 +++ b/xmpp.go Tue Mar 26 10:54:44 2013 -0600 @@ -188,7 +188,7 @@ } func startXmlReader(r io.Reader, -extStanza map[string]func(*xml.Name) interface{}) <-chan interface{} { + extStanza map[string]func(*xml.Name) interface{}) <-chan interface{} { ch := make(chan interface{}) go readXml(r, ch, extStanza) return ch @@ -269,8 +269,7 @@ func (cl *Client) StartSession(getRoster bool, pr *Presence) error { id := <-Id iq := &Iq{Header: Header{To: cl.Jid.Domain, Id: id, Type: "set", - Nested: []interface{}{Generic{XMLName: - xml.Name{Space: NsSession, Local: "session"}}}}} + Nested: []interface{}{Generic{XMLName: xml.Name{Space: NsSession, Local: "session"}}}}} ch := make(chan error) f := func(st Stanza) bool { iq, ok := st.(*Iq)