Run gofmt over code, it's been a while.

This commit is contained in:
Alex Bramley 2011-09-12 23:25:09 +01:00
parent 18c20080e8
commit c400a2141a
7 changed files with 53 additions and 54 deletions

View File

@ -40,7 +40,7 @@ func main() {
} }
// no point in sending empty lines down the channel // no point in sending empty lines down the channel
if len(s) > 2 { if len(s) > 2 {
in <- s[0:len(s)-1] in <- s[0 : len(s)-1]
} }
} }
}() }()

View File

@ -14,18 +14,18 @@ import "strings"
func (conn *Conn) Raw(rawline string) { conn.out <- rawline } func (conn *Conn) Raw(rawline string) { conn.out <- rawline }
// Pass() sends a PASS command to the server // Pass() sends a PASS command to the server
func (conn *Conn) Pass(password string) { conn.out <- "PASS "+password } func (conn *Conn) Pass(password string) { conn.out <- "PASS " + password }
// Nick() sends a NICK command to the server // Nick() sends a NICK command to the server
func (conn *Conn) Nick(nick string) { conn.out <- "NICK "+nick } func (conn *Conn) Nick(nick string) { conn.out <- "NICK " + nick }
// User() sends a USER command to the server // User() sends a USER command to the server
func (conn *Conn) User(ident, name string) { func (conn *Conn) User(ident, name string) {
conn.out <- "USER "+ident+" 12 * :"+name conn.out <- "USER " + ident + " 12 * :" + name
} }
// Join() sends a JOIN command to the server // Join() sends a JOIN command to the server
func (conn *Conn) Join(channel string) { conn.out <- "JOIN "+channel } func (conn *Conn) Join(channel string) { conn.out <- "JOIN " + channel }
// Part() sends a PART command to the server with an optional part message // Part() sends a PART command to the server with an optional part message
func (conn *Conn) Part(channel string, message ...string) { func (conn *Conn) Part(channel string, message ...string) {
@ -33,7 +33,7 @@ func (conn *Conn) Part(channel string, message ...string) {
if msg != "" { if msg != "" {
msg = " :" + msg msg = " :" + msg
} }
conn.out <- "PART "+channel+msg conn.out <- "PART " + channel + msg
} }
// Kick() sends a KICK command to remove a nick from a channel // Kick() sends a KICK command to remove a nick from a channel
@ -42,7 +42,7 @@ func (conn *Conn) Kick(channel, nick string, message ...string) {
if msg != "" { if msg != "" {
msg = " :" + msg msg = " :" + msg
} }
conn.out <- "KICK "+channel+" "+nick+msg conn.out <- "KICK " + channel + " " + nick + msg
} }
// Quit() sends a QUIT command to the server with an optional quit message // Quit() sends a QUIT command to the server with an optional quit message
@ -51,20 +51,20 @@ func (conn *Conn) Quit(message ...string) {
if msg == "" { if msg == "" {
msg = "GoBye!" msg = "GoBye!"
} }
conn.out <- "QUIT :"+msg conn.out <- "QUIT :" + msg
} }
// Whois() sends a WHOIS command to the server // Whois() sends a WHOIS command to the server
func (conn *Conn) Whois(nick string) { conn.out <- "WHOIS "+nick } func (conn *Conn) Whois(nick string) { conn.out <- "WHOIS " + nick }
//Who() sends a WHO command to the server //Who() sends a WHO command to the server
func (conn *Conn) Who(nick string) { conn.out <- "WHO "+nick } func (conn *Conn) Who(nick string) { conn.out <- "WHO " + nick }
// Privmsg() sends a PRIVMSG to the target t // Privmsg() sends a PRIVMSG to the target t
func (conn *Conn) Privmsg(t, msg string) { conn.out <- "PRIVMSG "+t+" :"+msg } func (conn *Conn) Privmsg(t, msg string) { conn.out <- "PRIVMSG " + t + " :" + msg }
// Notice() sends a NOTICE to the target t // Notice() sends a NOTICE to the target t
func (conn *Conn) Notice(t, msg string) { conn.out <- "NOTICE "+t+" :"+msg } func (conn *Conn) Notice(t, msg string) { conn.out <- "NOTICE " + t + " :" + msg }
// Ctcp() sends a (generic) CTCP message to the target t // Ctcp() sends a (generic) CTCP message to the target t
// with an optional argument // with an optional argument
@ -100,7 +100,7 @@ func (conn *Conn) Topic(channel string, topic ...string) {
if t != "" { if t != "" {
t = " :" + t t = " :" + t
} }
conn.out <- "TOPIC "+channel+t conn.out <- "TOPIC " + channel + t
} }
// Mode() sends a MODE command to the server. This one can get complicated if // Mode() sends a MODE command to the server. This one can get complicated if
@ -115,7 +115,7 @@ func (conn *Conn) Mode(t string, modestring ...string) {
if mode != "" { if mode != "" {
mode = " " + mode mode = " " + mode
} }
conn.out <- "MODE "+t+mode conn.out <- "MODE " + t + mode
} }
// Away() sends an AWAY command to the server // Away() sends an AWAY command to the server
@ -126,15 +126,15 @@ func (conn *Conn) Away(message ...string) {
if msg != "" { if msg != "" {
msg = " :" + msg msg = " :" + msg
} }
conn.out <- "AWAY"+msg conn.out <- "AWAY" + msg
} }
// Invite() sends an INVITE command to the server // Invite() sends an INVITE command to the server
func (conn *Conn) Invite(nick, channel string) { func (conn *Conn) Invite(nick, channel string) {
conn.out <- "INVITE "+nick+" "+channel conn.out <- "INVITE " + nick + " " + channel
} }
// Oper() sends an OPER command to the server // Oper() sends an OPER command to the server
func (conn *Conn) Oper(user, pass string) { func (conn *Conn) Oper(user, pass string) {
conn.out <- "OPER "+user+" "+pass conn.out <- "OPER " + user + " " + pass
} }

View File

@ -346,8 +346,8 @@ func TestMODE(t *testing.T) {
cm := test1.Modes cm := test1.Modes
// Verify the ChanPrivs exists and modes we're testing aren't set // Verify the ChanPrivs exists and modes we're testing aren't set
if cp, ok := user1.Channels[test1]; (!ok || c.Me.Channels[test1].Voice || if cp, ok := user1.Channels[test1]; !ok || c.Me.Channels[test1].Voice ||
cp.Op || cm.Key != "" || cm.InviteOnly || cm.Secret) { cp.Op || cm.Key != "" || cm.InviteOnly || cm.Secret {
t.Errorf("Channel privileges in unexpected state before MODE.") t.Errorf("Channel privileges in unexpected state before MODE.")
} }
@ -589,8 +589,7 @@ func Test353(t *testing.T) {
t.Errorf("353 handler failed to op known nick user1.") t.Errorf("353 handler failed to op known nick user1.")
} }
if p := get("user2"); if p := get("user2"); p == nil || p.Voice || p.HalfOp || p.Op || p.Admin || p.Owner {
p == nil || p.Voice || p.HalfOp || p.Op || p.Admin || p.Owner {
t.Errorf("353 handler set modes on new nick user2.") t.Errorf("353 handler set modes on new nick user2.")
} }

View File

@ -20,7 +20,7 @@ type mockNetConn struct {
rt, wt int64 rt, wt int64
} }
func MockNetConn(t *testing.T) (*mockNetConn) { func MockNetConn(t *testing.T) *mockNetConn {
// Our mock connection is a testing object // Our mock connection is a testing object
m := &mockNetConn{T: t} m := &mockNetConn{T: t}
m.closers = make([]chan bool, 0, 3) m.closers = make([]chan bool, 0, 3)
@ -78,13 +78,13 @@ func (m *mockNetConn) Expect(e string) {
t := time.NewTimer(5e6) t := time.NewTimer(5e6)
select { select {
case <-t.C: case <-t.C:
m.Errorf("Mock connection did not receive expected output.\n\t" + m.Errorf("Mock connection did not receive expected output.\n\t"+
"Expected: '%s', got nothing.", e) "Expected: '%s', got nothing.", e)
case s := <-m.Out: case s := <-m.Out:
t.Stop() t.Stop()
s = strings.Trim(s, "\r\n") s = strings.Trim(s, "\r\n")
if e != s { if e != s {
m.Errorf("Mock connection received unexpected value.\n\t" + m.Errorf("Mock connection received unexpected value.\n\t"+
"Expected: '%s'\n\tGot: '%s'", e, s) "Expected: '%s'\n\tGot: '%s'", e, s)
} }
} }
@ -97,7 +97,7 @@ func (m *mockNetConn) ExpectNothing() {
case s := <-m.Out: case s := <-m.Out:
t.Stop() t.Stop()
s = strings.Trim(s, "\r\n") s = strings.Trim(s, "\r\n")
m.Errorf("Mock connection received unexpected output.\n\t" + m.Errorf("Mock connection received unexpected output.\n\t"+
"Expected nothing, got: '%s'", s) "Expected nothing, got: '%s'", s)
} }
} }
@ -140,11 +140,11 @@ func (m *mockNetConn) Close() os.Error {
} }
func (m *mockNetConn) LocalAddr() net.Addr { func (m *mockNetConn) LocalAddr() net.Addr {
return &net.IPAddr{net.IPv4(127,0,0,1)} return &net.IPAddr{net.IPv4(127, 0, 0, 1)}
} }
func (m *mockNetConn) RemoteAddr() net.Addr { func (m *mockNetConn) RemoteAddr() net.Addr {
return &net.IPAddr{net.IPv4(127,0,0,1)} return &net.IPAddr{net.IPv4(127, 0, 0, 1)}
} }
func (m *mockNetConn) SetTimeout(ns int64) os.Error { func (m *mockNetConn) SetTimeout(ns int64) os.Error {

View File

@ -8,6 +8,7 @@ import (
) )
type HandlerID uint32 type HandlerID uint32
var hidCounter uint32 = 0 var hidCounter uint32 = 0
func NewHandlerID() HandlerID { func NewHandlerID() HandlerID {
@ -37,7 +38,7 @@ func NewHandler(h func(...interface{})) Handler {
} }
type EventDispatcher interface { type EventDispatcher interface {
Dispatch(name string, ev...interface{}) Dispatch(name string, ev ...interface{})
} }
type EventRegistry interface { type EventRegistry interface {

View File

@ -41,7 +41,7 @@ func TestParallelDispatch(t *testing.T) {
} }
// create some handlers and send an event to them // create some handlers and send an event to them
for _, t := range []int{5,11,2,15,8} { for _, t := range []int{5, 11, 2, 15, 8} {
r.AddHandler("send", factory(t)) r.AddHandler("send", factory(t))
} }
r.Dispatch("send") r.Dispatch("send")
@ -79,7 +79,7 @@ func TestSerialDispatch(t *testing.T) {
} }
// create some handlers and send an event to them // create some handlers and send an event to them
for _, t := range []int{5,11,2,15,8} { for _, t := range []int{5, 11, 2, 15, 8} {
r.AddHandler("send", factory(t)) r.AddHandler("send", factory(t))
} }
r.Dispatch("send") r.Dispatch("send")
@ -101,4 +101,3 @@ func TestSerialDispatch(t *testing.T) {
t.Fail() t.Fail()
} }
} }