code: func (cli *Client) waitPacket(packetc <-chan struct{}, timeout time.Duration, errTimeout error) {
  	defer cli.conn.wg.Done()
  
  	var timeoutc <-chan time.Time
  
  	if timeout > 0 {
  		timeoutc = time.After(timeout * time.Second)
  	}
  
  	select {
  	case <-packetc:
  	case <-timeoutc:
  		// Handle the timeout error.
  		cli.handleErrorAndDisconn(errTimeout)
  	}
  }
docs: // waitPacket waits for receiving the Packet.