Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding/binary: Read should document use of io.EOF vs io.ErrUnexpectedEOF #12016

Closed
joshlf opened this issue Aug 4, 2015 · 1 comment
Closed

Comments

@joshlf
Copy link

joshlf commented Aug 4, 2015

Just like io.ReadFull, encoding/binary.Read will return io.EOF if the given reader returns EOF before any bytes are read, but will return io.ErrUnexpectedEOF if some (but not all) of the bytes are read before encountering EOF (binary.Read just calls io.ReadFull under the hood). IMO, this behavior should be documented so that a) callers know about it and, b) callers can rely on the behavior not changing in the future (whereas, currently, a change in this behavior wouldn't break the documented API).

This concern was originally raised here on golang-nuts.

  • Version: 1.4.2
  • OS/Arch: linux/amd64
@mikioh mikioh changed the title encoding/binary.Read should document use of io.EOF vs io.ErrUnexpectedEOF encoding/binary: Read should document use of io.EOF vs io.ErrUnexpectedEOF Aug 4, 2015
@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Aug 4, 2015
@gopherbot
Copy link

CL https://golang.org/cl/15171 mentions this issue.

@golang golang locked and limited conversation to collaborators Oct 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants