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
io: document that ReadAtLeast and ReadFull can drop errors #20477
Comments
io ReadAtLeast doc |
That part doesn't say anything about the error returned if enough bytes are read, but later in the comment:
I think this could be clarified to:
|
The persistence of an error in a This is only relevant to documentation; documentation fixes are okay for Go1.9, but leaving in Go1.10 milestone. |
You're right about persistence of errors in |
Change https://golang.org/cl/102459 mentions this issue: |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?1.8.2
What operating system and processor architecture are you using (
go env
)?darwin amd64
What did you do?
When passing an io.Reader to io.ReadAtLeast or io.ReadFull, if the conditions of the function are fulfilled (i.e., enough bytes are returned) but it also returns an error, I would expect that error to be propagated. Instead, it is dropped. Example:
https://play.golang.org/p/3XvnMqGYMr
The behavior of these functions can't be changed because of backwards compatibility. I would argue that the function comment should call this case out specifically, since it's quite surprising (and even led to a bug in encoding/base32), and it seems that callers do want the error-propagating behavior most of the time.
Split off from #20044 .
The text was updated successfully, but these errors were encountered: