Skip to content

Commit

Permalink
Switch loop enumerator and extra defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
Micah-Kolide committed Mar 20, 2024
1 parent 5efc57f commit 2637d9c
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions ee/tables/execparsers/data_table/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ func WithDelimiter(delimiter string) parserOpt {
}

func NewParser(opts ...parserOpt) *parser {
p := &parser{
skipLines: 0,
headers: nil,
delimiter: "",
}
p := &parser{}

for _, opt := range opts {
opt(p)
Expand Down Expand Up @@ -91,8 +87,8 @@ func (p parser) parseLines(reader io.Reader) ([]map[string]string, error) {

// For each header, add the corresponding line field to the result row.
// Duplicate headers overwrite the set value. <-- Perhaps this should be different?
for c := 0; c < min; c++ {
row[strings.TrimSpace(p.headers[c])] = strings.TrimSpace(fields[c])
for i := 0; i < min; i++ {
row[strings.TrimSpace(p.headers[i])] = strings.TrimSpace(fields[i])
}

results = append(results, row)
Expand Down

0 comments on commit 2637d9c

Please sign in to comment.