You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When Read encounters an error or end-of-file condition after successfully reading n > 0 bytes, it returns the number of bytes read. It may return the (non-nil) error from the same call or return the error (and n == 0) from a subsequent call. An instance of this general case is that a Reader returning a non-zero number of bytes at the end of the input stream may return either err == EOF or err == nil. The next Read should return 0, EOF.
In the case where an io.Reader implementation returns a non-zero number of bytes read andio.EOF on a Read() call, a bufio.Reader buffering from one of these io.Reader implementations may return io.EOF even when it still has buffered data that has not been read. Specifically, this may happen when a slice with a zero length is given to (*bufio.Reader).Read() if it is not the first call to that method.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
It does.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
According to the docs for
io.Reader
:In the case where an
io.Reader
implementation returns a non-zero number of bytes read andio.EOF
on aRead()
call, abufio.Reader
buffering from one of theseio.Reader
implementations may returnio.EOF
even when it still has buffered data that has not been read. Specifically, this may happen when a slice with a zero length is given to(*bufio.Reader).Read()
if it is not the first call to that method.Here is a test showing the problem.
What did you expect to see?
That last
(*bufio.Reader).Read()
call should not have returnedio.EOF
unless there was no more buffered content.What did you see instead?
(*bufio.Reader).Read()
returnedio.EOF
even though there was more buffered content available for reading.The text was updated successfully, but these errors were encountered: