Skip to content

Instantly share code, notes, and snippets.

@xingma
xingma / read_line.go
Created October 25, 2017 01:36 — forked from kendellfab/read_line.go
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())
}
}