io.EOF

The sentinel error an io.Reader returns when there is no more data to read, meaning the stream ended normally.

In more detail

EOF stands for end of file. Loops that read a stream stop when they see io.EOF and treat it as success, not failure. Helpers such as io.ReadAll and io.Copy handle it for you and return a nil error at the end.

Example

if errors.Is(err, io.EOF) { break }

Related terms

Taught in

References