code: func (conn *Conn) Close() error {
  	// Guard against double-call of Close() if we get an error in send()
  	// as calling sock.Close() will cause recv() to receive EOF in readstring()
  	conn.mu.Lock()
  	if !conn.connected {
  		conn.mu.Unlock()
  		return nil
  	}
  	logging.Info("irc.Close(): Disconnected from server.")
  	conn.connected = false
  	err := conn.sock.Close()
  	close(conn.die)
  	// Drain both in and out channels to avoid a deadlock if the buffers
  	// have filled. See TestSendDeadlockOnFullBuffer in connection_test.go.
  	conn.drainIn()
  	conn.drainOut()
  	conn.wg.Wait()
  	conn.mu.Unlock()
  	// Dispatch after closing connection but before reinit
  	// so event handlers can still access state information.
  	conn.dispatch(&Line{Cmd: DISCONNECTED, Time: time.Now()})
  	return err
  }
docs: // Close tears down all connection-related state. It is called when either
  // the sending or receiving goroutines encounter an error.
  // It may also be used to forcibly shut down the connection to the server.