Bufio
bufio is Go’s standard-library package providing buffered input and output wrappers and utilities for incrementally processing streams.
Go in Action, Second Edition
bufio is Go's standard library package for buffered input and output, including scanner-based tokenization.
- How it is used
- Buffers file, network, and stream I/O while supporting line-oriented reading, tokenization, look-ahead, and efficient output.
- How deep it goes
- Explains buffering, system-call reduction, core types, line reads, peeking, writing, error handling, and flushing.
- Examples
- Demonstrates line scanning, input-format detection with Peek, buffered writing, and JSON/XML conversion.
- What you can do after
- Operate buffered readers and writers, process input incrementally, inspect prefixes, handle EOF, and flush output correctly.
Go in Practice, Second Edition
The Go bufio package provides buffered input and output wrappers and utilities for processing streams incrementally.
- How it is used
- Processes large, line-delimited files incrementally through buffered scanning instead of reading complete contents at once.
- How deep it goes
- Demonstrates Scanner and ScanLines in runnable code, while deferring deeper optimization and distributed processing.
- Examples
- Uses a structured.log file containing newline-delimited JSON records and extracts each record's level.
- What you can do after
- Build line-oriented Go processors that scan files incrementally and handle malformed records without stopping the entire stream.
Related concepts
- bufferingimplements · Buffering is the temporary storage of data or work between production and consumption to accommodate differences in processing rates, absorb interruptions, or improve transfer efficiency.
- bufio.Scannerhas part · bufio.Scanner is a Go type that reads input and advances through it as successive tokens.
- io.Writerimplements · io.Writer is a Go interface whose Write method accepts a byte sequence and returns the number of bytes written and any error.
- io.Readeruses · io.Reader is a Go standard-library interface whose Read method reads bytes into a supplied buffer and reports the number read and any error.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

