Exemplo n.º 1
0
// list
func encodeList(v []Any) (b []byte, err error) {
	list_len := len(v)
	var (
		lenB []byte
		tmpV []byte
	)

	b = append(b, 'V')

	if lenB, err = util.PackInt32(int32(list_len)); err != nil {
		b = nil
		return
	}
	b = append(b, 'l')
	b = append(b, lenB...)

	for _, a := range v {
		if tmpV, err = Encode(a); err != nil {
			b = nil
			return
		}
		b = append(b, tmpV...)
	}
	b = append(b, 'z')
	return
}
Exemplo n.º 2
0
// int
func encodeInt32(v int32) (b []byte, err error) {
	var tmpV []byte
	if tmpV, err = util.PackInt32(v); err != nil {
		b = nil
		return
	}
	b = append(b, 'I')
	b = append(b, tmpV...)
	return
}