Last Updated: May 22, 2026
The bufio package wraps a file (or any reader/writer) in an in-memory buffer so a program doesn't pay the cost of a syscall on every byte. It also provides higher-level helpers like Scanner, which is the idiomatic way to read a file line by line. This lesson covers when buffering matters, the three main types (Reader, Writer, Scanner), the methods you'll use most, and two common mistakes: forgetting to flush, and Scanner's silent line-length limit.