"encoding/binary"
"fmt"
"io"
+ "math"
"sort"
"strconv"
"strings"
t, err := s.ReadString('\n')
if err != nil {
if err == io.EOF {
+ if t != "" {
+ return nil, fmt.Errorf(
+ "no newline in last line: %q",
+ t)
+ }
break
}
return nil, err
}
// And the group members concatenated as above
data.Write(mems.Bytes())
+ // Ensure the offsets can fit the length of this entry
+ if data.Len() > math.MaxUint16 {
+ return nil, fmt.Errorf("group too large to serialize: %v, %v",
+ data.Len(), g)
+ }
size := uint16(data.Len())
var res bytes.Buffer // serialized result