Table of Contents

bufio package

What is it?

`bufio` implements buffered I/O by wrapping an `io.Reader` or `io.Writer` and using an in-memory buffer to make reading/writing more efficient.

What is it used for?

Common types

Example: buffered reading (lines)

r := bufio.NewReader(f)
line, err := r.ReadString('\n')
_ = line
_ = err

Example: buffered writing

w := bufio.NewWriter(f)
_, _ = w.WriteString("hello\n")
_ = w.Flush()

Notes / pitfalls

Hard words (English)