Skip to content

Commit

Permalink
simplify reading lines
Browse files Browse the repository at this point in the history
  • Loading branch information
kvch committed May 30, 2018
1 parent 12e2a58 commit e982a79
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 21 deletions.
2 changes: 1 addition & 1 deletion auditbeat/include/fields.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion filebeat/include/fields.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion heartbeat/include/fields.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 6 additions & 15 deletions libbeat/generator/fields/fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package fields
import (
"bufio"
"fmt"
"io"
"io/ioutil"
"os"
"path"
Expand Down Expand Up @@ -55,25 +54,17 @@ func writeGeneratedFieldsYml(beatsPath string, fieldFiles []*YmlFile) error {
return err
}

fr := bufio.NewReader(ff)
for {
l, err := fr.ReadString('\n')
if err != nil {
if err == io.EOF {
err = writeIndentedLine(fw, l+"\n", p.Indent)
if err != nil {
return err
}
break
}
return err
}
err = writeIndentedLine(fw, l, p.Indent)
fs := bufio.NewScanner(ff)
for fs.Scan() {
err = writeIndentedLine(fw, fs.Text()+"\n", p.Indent)
if err != nil {
return err
}

}
if err := fs.Err(); err != nil {
return err
}
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/include/fields.go

Large diffs are not rendered by default.

Loading

0 comments on commit e982a79

Please sign in to comment.