Go Package bufio: Difference between revisions
Jump to navigation
Jump to search
Line 3: | Line 3: | ||
=Internal= | =Internal= | ||
* [[Go_Language_Modularization#bufio|Standard Library]] | * [[Go_Language_Modularization#bufio|Standard Library]] | ||
* [[File_Operations_in_Go#Line_by_Line|File Operations in Go]] | |||
=Overview= | =Overview= | ||
=Reading a Text File Line by Line= | =Reading a Text File Line by Line= |
Revision as of 23:26, 10 January 2024
External
Internal
Overview
Reading a Text File Line by Line
import (
"bufio"
"os"
)
f, err := os.Open("/Users/ovidiu/tmp/adc.txt")
if err != nil {
...
}
defer f.Close()
scanner := bufio.NewScanner(f)
scanner.Split(bufio.ScanLines)
for scanner.Scan() {
line := scanner.Text()
...
}