From d119e6bca0760c8bd919e0e6fec41b7090c8a941 Mon Sep 17 00:00:00 2001 From: Alex Bramley Date: Thu, 6 Oct 2011 21:28:01 +0100 Subject: [PATCH] Update example client. --- client.go | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/client.go b/client.go index 3a56b4b..d90d8b1 100644 --- a/client.go +++ b/client.go @@ -20,12 +20,6 @@ func main() { c.AddHandler("disconnected", func(conn *irc.Conn, line *irc.Line) { quit <- true }) - // connect to server - if err := c.Connect("irc.freenode.net"); err != nil { - fmt.Printf("Connection error: %s\n", err) - return - } - // set up a goroutine to read commands from stdin in := make(chan string, 4) reallyquit := false @@ -80,17 +74,13 @@ func main() { }() for !reallyquit { - select { - case err := <-c.Err: - fmt.Printf("goirc error: %s\n", err) - case <-quit: - if !reallyquit { - fmt.Println("Reconnecting...") - if err := c.Connect("irc.freenode.net"); err != nil { - fmt.Printf("Connection error: %s\n", err) - reallyquit = true - } - } + // connect to server + if err := c.Connect("irc.freenode.net"); err != nil { + fmt.Printf("Connection error: %s\n", err) + return } + + // wait on quit channel + <-quit } }