// Parse parses passfile entries from the reader.
Parse parses passfile entries from the reader.
// Parse parses passfile entries from the reader .
func Parse(r io.Reader) ([]Entry, error) {
	var entries []Entry
	i, s := 0, bufio.NewScanner(r)
	for s.Scan() {
		i++
		line := strings.TrimSpace(commentRE.ReplaceAllString(s.Text(), ""))
		if line == "" {
			continue
		}
		v := strings.Split(line, ":")
		if len(v) != 6 {
			return nil, &ErrInvalidEntry{i}
		}
		for j := 0; j < len(v); j++ {
			if v[j] == "" {
				return nil, &ErrEmptyField{i, j}
			}
		}
		entries = append(entries, NewEntry(v))
	}
	return entries, nil
}
func Parse ( r io . Reader ) ( [ ] Entry , error ) { var entries [ ] Entry i , s := 0 , bufio . NewScanner ( r ) for s . Scan ( ) { i ++ line := strings . TrimSpace ( commentRE . ReplaceAllString ( s . Text ( ) , " " ) ) if line == " " { continue } v := strings . Split ( line , " " ) if len ( v ) != 6 { return nil , & ErrInvalidEntry { i } } for j := 0 ; j < len ( v ) ; j ++ { if v [ j ] == " " { return nil , & ErrEmptyField { i , j } } } entries = append ( entries , NewEntry ( v ) ) } return entries , nil }
Parse parses passfile entries from the reader.
Parse parses passfile entries from the reader .
// grab next line // split and check length // make sure no blank entries exist