X-Git-Url: https://ruderich.org/simon/gitweb/?p=nsscash%2Fnsscash.git;a=blobdiff_plain;f=group.go;h=126ebb0dc349e0127c4ff14f3b61f48cb99cc737;hp=214f91438d78740a331c487cbfe5ecab1355718c;hb=7adc7f83eddd37aa372aa10159128b6d16c4320a;hpb=c6b898ea9ab372c58c59658c2acf17ea831d71db diff --git a/group.go b/group.go index 214f914..126ebb0 100644 --- a/group.go +++ b/group.go @@ -102,7 +102,7 @@ func ParseGroups(r io.Reader) ([]Group, error) { return res, nil } -func SerializeGroup(g Group) []byte { +func SerializeGroup(g Group) ([]byte, error) { le := binary.LittleEndian // Concatenate all (NUL-terminated) strings and store the offsets @@ -158,7 +158,7 @@ func SerializeGroup(g Group) []byte { // struct are 8 byte aligned alignBufferTo(&res, 8) - return res.Bytes() + return res.Bytes(), nil } func SerializeGroups(w io.Writer, grs []Group) error { @@ -168,7 +168,11 @@ func SerializeGroups(w io.Writer, grs []Group) error { for _, g := range grs { // TODO: warn about duplicate entries offsets[toKey(g)] = uint64(data.Len()) - data.Write(SerializeGroup(g)) + x, err := SerializeGroup(g) + if err != nil { + return err + } + data.Write(x) } // Copy to prevent sorting from modifying the argument