Created
July 18, 2015 17:35
-
-
Save pagoenka/80fd2faa2ee2ac5b646d to your computer and use it in GitHub Desktop.
Reading file, line by line in Go lang using scanner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"fmt" | |
"os" | |
) | |
func main() { | |
fileHandle, _ := os.Open("file_name.txt") | |
defer fileHandle.Close() | |
fileScanner := bufio.NewScanner(fileHandle) | |
for fileScanner.Scan() { | |
fmt.Println(fileScanner.Text()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment