# HG changeset patch # User Chris Jones # Date 1326997536 21600 # Node ID e619e18dcec3fa72f1e248fe00732175d309c4eb # Parent acca351fb8f09985fdf91a9b635085ec2db7b543 Ran gofix from weekly-2012-01-15. diff -r acca351fb8f0 -r e619e18dcec3 roster.go --- a/roster.go Thu Jan 19 11:06:42 2012 -0600 +++ b/roster.go Thu Jan 19 12:25:36 2012 -0600 @@ -5,9 +5,10 @@ package xmpp import ( + "errors" "fmt" - "os" - "xml" + + "encoding/xml" ) // This file contains support for roster management, RFC 3921, Section 7. @@ -46,12 +47,12 @@ // Synchronously fetch this entity's roster from the server and cache // that information. This is called once from a fairly deep call stack // as part of XMPP negotiation. -func fetchRoster(client *Client) os.Error { +func fetchRoster(client *Client) error { rosterUpdate := rosterClients[client.Uid].rosterUpdate iq := &Iq{From: client.Jid.String(), Id: <-Id, Type: "get", Nested: []interface{}{RosterQuery{}}} - ch := make(chan os.Error) + ch := make(chan error) f := func(st Stanza) bool { defer close(ch) if iq.Type == "error" { @@ -66,7 +67,7 @@ } } if rq == nil { - ch <- os.NewError(fmt.Sprintf( + ch <- errors.New(fmt.Sprintf( "Roster query result not query: %v", st)) return false } @@ -131,7 +132,7 @@ select { case newIt := <-rosterUpdate: if newIt.Subscription == "remove" { - roster[newIt.Jid] = RosterItem{}, false + delete(roster, newIt.Jid) } else { roster[newIt.Jid] = newIt } diff -r acca351fb8f0 -r e619e18dcec3 roster_test.go --- a/roster_test.go Thu Jan 19 11:06:42 2012 -0600 +++ b/roster_test.go Thu Jan 19 12:25:36 2012 -0600 @@ -5,10 +5,10 @@ package xmpp import ( + "encoding/xml" "reflect" "strings" "testing" - "xml" ) // This is mostly just tests of the roster data structures. diff -r acca351fb8f0 -r e619e18dcec3 stream.go --- a/stream.go Thu Jan 19 11:06:42 2012 -0600 +++ b/stream.go Thu Jan 19 12:25:36 2012 -0600 @@ -11,20 +11,19 @@ package xmpp import ( - "big" "crypto/md5" "crypto/rand" "crypto/tls" "encoding/base64" + "encoding/xml" "fmt" "io" + "log/syslog" + "math/big" "net" - "os" "regexp" "strings" - "syslog" "time" - "xml" ) // Callback to handle a stanza with a particular id. @@ -53,14 +52,14 @@ } } if Log != nil { - Log.Err("read: " + err.String()) + Log.Err("read: " + err.Error()) } break } nw, err := w.Write(p[:nr]) if nw < nr { if Log != nil { - Log.Err("read: " + err.String()) + Log.Err("read: " + err.Error()) } break } @@ -74,14 +73,14 @@ nr, err := r.Read(p) if nr == 0 { if Log != nil { - Log.Err("write: " + err.String()) + Log.Err("write: " + err.Error()) } break } nw, err := cl.socket.Write(p[:nr]) if nw < nr { if Log != nil { - Log.Err("write: " + err.String()) + Log.Err("write: " + err.Error()) } break } @@ -89,7 +88,7 @@ } func readXml(r io.Reader, ch chan<- interface{}, -extStanza map[string]func(*xml.Name) interface{}) { + extStanza map[string]func(*xml.Name) interface{}) { if Loglevel >= syslog.LOG_DEBUG { pr, pw := io.Pipe() go tee(r, pw, "S: ") @@ -103,9 +102,9 @@ // Sniff the next token on the stream. t, err := p.Token() if t == nil { - if err != os.EOF { + if err != io.EOF { if Log != nil { - Log.Err("read: " + err.String()) + Log.Err("read: " + err.Error()) } } break @@ -124,7 +123,7 @@ if err != nil { if Log != nil { Log.Err("unmarshal stream: " + - err.String()) + err.Error()) } break Loop } @@ -157,7 +156,7 @@ err = p.Unmarshal(obj, &se) if err != nil { if Log != nil { - Log.Err("unmarshal: " + err.String()) + Log.Err("unmarshal: " + err.Error()) } break Loop } @@ -170,7 +169,7 @@ if err != nil { if Log != nil { Log.Err("ext unmarshal: " + - err.String()) + err.Error()) } break Loop } @@ -181,14 +180,14 @@ } } -func parseExtended(st Stanza, extStanza map[string]func(*xml.Name) interface{}) os.Error { +func parseExtended(st Stanza, extStanza map[string]func(*xml.Name) interface{}) error { // Now parse the stanza's innerxml to find the string that we // can unmarshal this nested element from. reader := strings.NewReader(st.innerxml()) p := xml.NewParser(reader) for { t, err := p.Token() - if err == os.EOF { + if err == io.EOF { break } if err != nil { @@ -229,7 +228,7 @@ err := xml.Marshal(w, obj) if err != nil { if Log != nil { - Log.Err("write: " + err.String()) + Log.Err("write: " + err.Error()) } break } @@ -292,7 +291,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 @@ -327,7 +326,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 { @@ -464,7 +463,7 @@ if err != nil { if Log != nil { Log.Err("SASL challenge decode: " + - err.String()) + err.Error()) } return } @@ -531,7 +530,7 @@ cnonce, err := rand.Int(rand.Reader, randSize) if err != nil { if Log != nil { - Log.Err("SASL rand: " + err.String()) + Log.Err("SASL rand: " + err.Error()) } return } @@ -605,11 +604,11 @@ // 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)) - return h.Sum() + return h.Sum(nil) } hex := func(bytes []byte) string { return fmt.Sprintf("%x", bytes) diff -r acca351fb8f0 -r e619e18dcec3 structs.go --- a/structs.go Thu Jan 19 11:06:42 2012 -0600 +++ b/structs.go Thu Jan 19 12:25:36 2012 -0600 @@ -8,13 +8,13 @@ import ( "bytes" + "encoding/xml" + "errors" "flag" "fmt" "io" - "os" "regexp" "strings" - "xml" ) // JID represents an entity that can communicate with other @@ -164,7 +164,7 @@ Any *Generic } -var _ os.Error = &Error{} +var _ error = &Error{} // Used for resource binding as a nested element inside . type bindIq struct { @@ -207,7 +207,7 @@ return true } -func (s *stream) MarshalXML() ([]byte, os.Error) { +func (s *stream) MarshalXML() ([]byte, error) { buf := bytes.NewBuffer(nil) buf.WriteString("") xml.Marshal(buf, s.Any) @@ -257,7 +257,7 @@ return buf.Bytes(), nil } -func (e *errText) MarshalXML() ([]byte, os.Error) { +func (e *errText) MarshalXML() ([]byte, error) { buf := bytes.NewBuffer(nil) buf.WriteString("