bufio
I/Oimport "bufio"Implements buffered I/O wrapping io.Reader and io.Writer for efficient reading and writing.
Example
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
fmt.Println(scanner.Text())
}
}Key Types & Functions
ScannerReaderWriterNewScannerNewReaderAbout bufio
The bufio package (imported as bufio) belongs to the I/O category of Go packages. Implements buffered I/O wrapping io.Reader and io.Writer for efficient reading and writing.
Go's standard library is one of the language's greatest strengths, providing production-ready implementations for networking, cryptography, encoding, I/O, and more. The bufio package follows Go's philosophy of simplicity and composability — small, focused packages that combine through interfaces like io.Reader and io.Writer.
When using bufio in production, follow Go best practices: handle errors explicitly, use context for cancellation and timeouts, prefer composition over inheritance, and write table-driven tests. The Go documentation at pkg.go.dev provides comprehensive API references and examples for every exported type and function.