Ejemplo n.º 1
0
// EncodeBytesValue encodes a byte array value, appends it to the supplied
// buffer, and returns the final buffer.
func EncodeBytesValue(appendTo []byte, data []byte, delimited bool) []byte {
	if delimited {
		appendTo = append(appendTo, byte(ValueType_DELIMITED_BYTES))
		appendTo = encoding.EncodeNonsortingVarint(appendTo, int64(len(data)))
	} else {
		appendTo = append(appendTo, byte(ValueType_BYTES))
	}
	return append(appendTo, data...)
}
Ejemplo n.º 2
0
// EncodeIntValue encodes an int value, appends it to the supplied buffer, and
// returns the final buffer.
func EncodeIntValue(appendTo []byte, i int64) []byte {
	appendTo = append(appendTo, byte(ValueType_INT))
	return encoding.EncodeNonsortingVarint(appendTo, i)
}