Skip to content

Instantly share code, notes, and snippets.

@guozengxin
Created July 12, 2017 06:50
Show Gist options
  • Save guozengxin/6114e5efd594788df97674a65c656645 to your computer and use it in GitHub Desktop.
Save guozengxin/6114e5efd594788df97674a65c656645 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