Skip to content

Commit

Permalink
helper for reading files
Browse files Browse the repository at this point in the history
  • Loading branch information
raspi committed Jan 9, 2020
1 parent e97ee20 commit 81a7407
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions update.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,19 @@ func GetChecksumsFromFile(chtype checksumType, path string, prefix string, suffi

return f
}

// Read a file and split with new line separator
func GetLinesFromFile(path string) (lines []string, err error) {
b, err := ioutil.ReadFile(path)
if err != nil {
return nil, err
}

sc := bufio.NewScanner(bytes.NewReader(b))

for sc.Scan() {
lines = append(lines, sc.Text())
}

return lines, nil
}

0 comments on commit 81a7407

Please sign in to comment.