code: func (e *Encoder) Write(pkt Generic, async bool) error {
  	// reset and eventually grow buffer
  	packetLength := pkt.Len()
  	e.buffer.Reset()
  	e.buffer.Grow(packetLength)
  	buf := e.buffer.Bytes()[0:packetLength]
  
  	// encode packet
  	_, err := pkt.Encode(buf)
  	if err != nil {
  		return err
  	}
  
  	// write buffer
  	if async {
  		_, err = e.writer.Write(buf)
  	} else {
  		_, err = e.writer.WriteAndFlush(buf)
  	}
  	if err != nil {
  		return err
  	}
  
  	return nil
  }
docs: // Write encodes and writes the passed packet to the write buffer.