in internal/encoding/types.go [782:843]
func (a *arrayUint64) Unmarshal(r *buffer.Buffer) error {
length, err := readArrayHeader(r)
if err != nil {
return err
}
aa := (*a)[:0]
type_, err := readType(r)
if err != nil {
return err
}
switch type_ {
case TypeCodeUlong0:
if int64(cap(aa)) < length {
aa = make([]uint64, length)
} else {
aa = aa[:length]
for i := range aa {
aa[i] = 0
}
}
case TypeCodeSmallUlong:
buf, ok := r.Next(length)
if !ok {
return errors.New("invalid length")
}
if int64(cap(aa)) < length {
aa = make([]uint64, length)
} else {
aa = aa[:length]
}
for i, n := range buf {
aa[i] = uint64(n)
}
case TypeCodeUlong:
const typeSize = 8
buf, ok := r.Next(length * typeSize)
if !ok {
return errors.New("invalid length")
}
if int64(cap(aa)) < length {
aa = make([]uint64, length)
} else {
aa = aa[:length]
}
var bufIdx int
for i := range aa {
aa[i] = binary.BigEndian.Uint64(buf[bufIdx : bufIdx+8])
bufIdx += 8
}
default:
return fmt.Errorf("invalid type for []uint64 %02x", type_)
}
*a = aa
return nil
}