code: func (p *pktline) writePacket(data []byte) error {
  	if len(data) > MaxPacketLength {
  		return errors.New("Packet length exceeds maximal length")
  	}
  
  	if _, err := p.w.WriteString(fmt.Sprintf("%04x", len(data)+4)); err != nil {
  		return err
  	}
  
  	if _, err := p.w.Write(data); err != nil {
  		return err
  	}
  
  	return nil
  }
docs: // writePacket writes the given data in "data" to the underlying data stream
  // using Git's `pkt-line` format.
  //
  // If the data was longer than MaxPacketLength, an error will be returned. If
  // there was any error encountered while writing any component of the packet
  // (hdr, payload), it will be returned.
  //
  // NB: writePacket does _not_ flush the underlying buffered writer. See instead:
  // `writeFlush()`.