The bufio package
The functions of the bufio package allow you to perform buffered file operations, which means that although its operations look similar to the ones found in io, they work in a slightly different way.
What bufio actually does is to wrap an io.Reader or io.Writer object into a new value that implements the required interface while providing buffering to the new value. One of the handy features of the bufio package is that it allows you to read a text file line by line, word by word, and character by character without too much effort.
Once again, an example will try to clarify things: the name of the Go file that showcases the use of bufio is bufIO.go and will be presented in four parts.
The first part is the expected preamble: ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access