io.ReadAll

The Go function that reads an io.Reader until the end and returns everything as one slice of bytes.

In more detail

It holds the whole stream in memory, which is fine for small trusted input and dangerous for anything unbounded. Wrap untrusted sources in io.LimitReader first.

Example

data, err := io.ReadAll(reader)

Related terms

Taught in

References