code: func writeTo4VariantDictionary(w io.Writer, id uint8, data *VariantDictionary) error {
  	if data != nil {
  		var buffer bytes.Buffer
  		if err := binary.Write(&buffer, binary.LittleEndian, data.Version); err != nil {
  			return err
  		}
  		for _, item := range data.Items {
  			if err := binary.Write(&buffer, binary.LittleEndian, item.Type); err != nil {
  				return err
  			}
  			if err := binary.Write(&buffer, binary.LittleEndian, item.NameLength); err != nil {
  				return err
  			}
  			if err := binary.Write(&buffer, binary.LittleEndian, item.Name); err != nil {
  				return err
  			}
  			if err := binary.Write(&buffer, binary.LittleEndian, item.ValueLength); err != nil {
  				return err
  			}
  			if err := binary.Write(&buffer, binary.LittleEndian, item.Value); err != nil {
  				return err
  			}
  		}
  		if err := binary.Write(&buffer, binary.LittleEndian, []byte{0x00}); err != nil {
  			return err
  		}
  
  		// Write to original writer
  		if err := binary.Write(w, binary.LittleEndian, id); err != nil {
  			return err
  		}
  		if err := binary.Write(w, binary.LittleEndian, uint32(buffer.Len())); err != nil {
  			return err
  		}
  		if err := binary.Write(w, binary.LittleEndian, buffer.Bytes()); err != nil {
  			return err
  		}
  	}
  	return nil
  }
docs: // writeTo31Header is an helper to write a variant dictionary to the given io.Writer