Home

ioEOF

io.EOF is a sentinel error value in the Go standard library that signals the end of input in I/O operations. Defined in the io package, it is used by many readers to indicate that no more data is available from the underlying source.

In Go's I/O model, the Read method of an io.Reader returns two values: the number of bytes

Common usage patterns involve looping over a stream and checking for io.EOF after each Read. With newer

io.EOF is not an indication of an exceptional failure; it is a normal condition that marks the

Related concepts include other errors in the io package (such as io.ErrShortBuffer and io.ErrUnexpectedEOF) and interfaces

read
and
an
error.
When
the
end
of
the
input
is
reached,
Read
typically
returns
the
number
of
bytes
read
(which
may
be
zero)
and
the
error
io.EOF.
Some
implementations
may
return
data
and
io.EOF
together
in
the
same
call.
Programs
are
expected
to
handle
both
the
data
and
the
end-of-file
signal,
continuing
until
an
EOF
is
observed.
Go
error
inspection
utilities,
developers
can
also
use
errors.Is(err,
io.EOF)
to
detect
the
end
of
input,
which
supports
error
wrapping
and
enhances
compatibility.
natural
end
of
a
data
stream.
It
can
arise
from
various
sources,
such
as
files,
network
connections,
or
in-memory
readers.
like
io.Reader,
io.Writer,
and
io.ReaderAt.
Understanding
io.EOF
helps
ensure
correct
and
efficient
handling
of
streaming
data
across
different
I/O
sources.