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

Taught in

References