code: func WriteVarInt(w io.Writer, pver uint32, val uint64) error {
  	if val < 0xfd {
  		return binarySerializer.PutUint8(w, uint8(val))
  	}
  
  	if val <= math.MaxUint16 {
  		err := binarySerializer.PutUint8(w, 0xfd)
  		if err != nil {
  			return err
  		}
  		return binarySerializer.PutUint16(w, littleEndian, uint16(val))
  	}
  
  	if val <= math.MaxUint32 {
  		err := binarySerializer.PutUint8(w, 0xfe)
  		if err != nil {
  			return err
  		}
  		return binarySerializer.PutUint32(w, littleEndian, uint32(val))
  	}
  
  	err := binarySerializer.PutUint8(w, 0xff)
  	if err != nil {
  		return err
  	}
  	return binarySerializer.PutUint64(w, littleEndian, val)
  }
docs: // WriteVarInt serializes val to w using a variable number of bytes depending
  // on its value.