Skip to content

Instantly share code, notes, and snippets.

@brpaz
Created March 16, 2019 10:07
Show Gist options
  • Save brpaz/c0ea4b600ff3743638f2e2fb35eb5255 to your computer and use it in GitHub Desktop.
Save brpaz/c0ea4b600ff3743638f2e2fb35eb5255 to your computer and use it in GitHub Desktop.
func scanFile() {
f, err := os.OpenFile(logfile, os.O_RDONLY, os.ModePerm)
if err != nil {
log.Fatalf("open file error: %v", err)
return
}
defer f.Close()
sc := bufio.NewScanner(f)
for sc.Scan() {
_ = sc.Text() // GET the line string
}
if err := sc.Err(); err != nil {
log.Fatalf("scan file error: %v", err)
return
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment