gofix weekly fixes for client.

This commit is contained in:
Alex Bramley 2011-11-13 13:34:32 +00:00
parent 81eb9ee3df
commit 9d5159a220
2 changed files with 30 additions and 28 deletions

View File

@ -3,12 +3,13 @@ package client
import (
"bufio"
"crypto/tls"
"errors"
"fmt"
"github.com/fluffle/goirc/event"
"github.com/fluffle/goirc/logging"
"github.com/fluffle/goirc/state"
"fmt"
"net"
"os"
"strings"
"time"
)
@ -146,9 +147,9 @@ func (conn *Conn) initialise() {
// on the connection to the IRC server, set Conn.SSL to true before calling
// Connect(). The port will default to 6697 if ssl is enabled, and 6667
// otherwise. You can also provide an optional connect password.
func (conn *Conn) Connect(host string, pass ...string) os.Error {
func (conn *Conn) Connect(host string, pass ...string) error {
if conn.Connected {
return os.NewError(fmt.Sprintf(
return errors.New(fmt.Sprintf(
"irc.Connect(): already connected to %s, cannot connect to %s",
conn.Host, host))
}
@ -220,7 +221,7 @@ func (conn *Conn) recv() {
for {
s, err := conn.io.ReadString('\n')
if err != nil {
conn.l.Error("irc.recv(): %s", err.String())
conn.l.Error("irc.recv(): %s", err.Error())
conn.shutdown()
return
}
@ -262,12 +263,12 @@ func (conn *Conn) write(line string) {
}
if _, err := conn.io.WriteString(line + "\r\n"); err != nil {
conn.l.Error("irc.send(): %s", err.String())
conn.l.Error("irc.send(): %s", err.Error())
conn.shutdown()
return
}
if err := conn.io.Flush(); err != nil {
conn.l.Error("irc.send(): %s", err.String())
conn.l.Error("irc.send(): %s", err.Error())
conn.shutdown()
return
}

View File

@ -1,6 +1,7 @@
package client
import (
"io"
"net"
"os"
"strings"
@ -96,7 +97,7 @@ func (m *mockNetConn) ExpectNothing() {
}
// Implement net.Conn interface
func (m *mockNetConn) Read(b []byte) (int, os.Error) {
func (m *mockNetConn) Read(b []byte) (int, error) {
if m.closed {
return 0, os.EINVAL
}
@ -106,12 +107,12 @@ func (m *mockNetConn) Read(b []byte) (int, os.Error) {
l = len(s)
copy(b, s)
case <-m.closers[mockReadCloser]:
return 0, os.EOF
return 0, io.EOF
}
return l, nil
}
func (m *mockNetConn) Write(s []byte) (int, os.Error) {
func (m *mockNetConn) Write(s []byte) (int, error) {
if m.closed {
return 0, os.EINVAL
}
@ -121,7 +122,7 @@ func (m *mockNetConn) Write(s []byte) (int, os.Error) {
return len(s), nil
}
func (m *mockNetConn) Close() os.Error {
func (m *mockNetConn) Close() error {
if m.closed {
return os.EINVAL
}
@ -142,18 +143,18 @@ func (m *mockNetConn) RemoteAddr() net.Addr {
return &net.IPAddr{net.IPv4(127, 0, 0, 1)}
}
func (m *mockNetConn) SetTimeout(ns int64) os.Error {
func (m *mockNetConn) SetTimeout(ns int64) error {
m.rt = ns
m.wt = ns
return nil
}
func (m *mockNetConn) SetReadTimeout(ns int64) os.Error {
func (m *mockNetConn) SetReadTimeout(ns int64) error {
m.rt = ns
return nil
}
func (m *mockNetConn) SetWriteTimeout(ns int64) os.Error {
func (m *mockNetConn) SetWriteTimeout(ns int64) error {
m.wt = ns
return nil
}