Skip to content

Commit 8a030b4

Browse files
committed
migrate hostsfile parser from deprecated fileutil.ReadFile to fileutil.Lines iterator
1 parent 812ee6f commit 8a030b4

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

hostsfile/hostsfile.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,13 @@ func Parse(p string) (map[string][]string, error) {
3636
return nil, errors.New("hosts file doesn't exist")
3737
}
3838

39-
hostsFileCh, err := fileutil.ReadFile(p)
40-
if err != nil {
41-
return nil, err
42-
}
43-
4439
items := make(map[string][]string)
4540
lineCount := 0
4641

47-
for line := range hostsFileCh {
42+
for line, err := range fileutil.Lines(p) {
43+
if err != nil {
44+
return nil, err
45+
}
4846
lineCount++
4947
if lineCount > MaxLines {
5048
break

0 commit comments

Comments
 (0)