io.Reader

The Go interface for anything you can read bytes from, such as a file, a network connection or an HTTP response body.

In more detail

It has one method, Read, which fills a byte slice and returns how many bytes it read and an error, with io.EOF meaning the end. Writing functions to accept an io.Reader instead of a file name makes them work with any source and easy to test.

Example

reader := strings.NewReader("0123456789")

Related terms

Taught in

References