X-Git-Url: https://ruderich.org/simon/gitweb/?p=nsscash%2Fnsscash.git;a=blobdiff_plain;f=group.go;h=214f91438d78740a331c487cbfe5ecab1355718c;hp=0ad86711431d068ff0922ceace8c39cdba01a1a0;hb=c6b898ea9ab372c58c59658c2acf17ea831d71db;hpb=424a573023a06c50fd8dad43174c12c42f7dada5 diff --git a/group.go b/group.go index 0ad8671..214f914 100644 --- a/group.go +++ b/group.go @@ -62,9 +62,15 @@ func toKey(g Group) GroupKey { func ParseGroups(r io.Reader) ([]Group, error) { var res []Group - s := bufio.NewScanner(r) - for s.Scan() { - t := s.Text() + s := bufio.NewReader(r) + for { + t, err := s.ReadString('\n') + if err != nil { + if err == io.EOF { + break + } + return nil, err + } x := strings.Split(t, ":") if len(x) != 4 { @@ -76,6 +82,9 @@ func ParseGroups(r io.Reader) ([]Group, error) { return nil, errors.Wrapf(err, "invalid gid in line %q", t) } + // ReadString() contains the delimiter + x[3] = strings.TrimSuffix(x[3], "\n") + var members []string // No members must result in empty slice, not slice with the // empty string @@ -89,10 +98,6 @@ func ParseGroups(r io.Reader) ([]Group, error) { Members: members, }) } - err := s.Err() - if err != nil { - return nil, err - } return res, nil }