Skip to content

Instantly share code, notes, and snippets.

@kevsersrca
Forked from kendellfab/read_line.go
Created August 27, 2019 08:09
Show Gist options
  • Save kevsersrca/f36f664ed6d893f61c5d073bc3a77a54 to your computer and use it in GitHub Desktop.
Save kevsersrca/f36f664ed6d893f61c5d073bc3a77a54 to your computer and use it in GitHub Desktop.
Golang --> Read file line by line.
func readLine(path string) {
inFile, _ := os.Open(path)
defer inFile.Close()
scanner := bufio.NewScanner(inFile)
scanner.Split(bufio.ScanLines)
for scanner.Scan() {
fmt.Println(scanner.Text())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment