bytes.Buffer
A growable in-memory buffer of bytes from Go's bytes package that works as both an io.Reader and an io.Writer.
In more detail
It is handy in tests and examples to capture output or supply input without files. Its String method returns the contents as text.
Example
source := bytes.NewBufferString("logs ready")Related terms
- io.Reader — The Go interface for anything you can read bytes from, such as a file, a network connection or an HTTP response body.
- io.Writer — The Go interface for anything you can write bytes to, such as a file, standard output, a buffer or an HTTP response.
- byte slice — A Go slice of bytes, the raw form data takes when it is read from or written to files, networks and encoders.
Taught in
- Streams and the io Package — Concurrent Systems Programming with Go