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

io: document whether LimitedReader.Read returns EOF or ErrUnexpectedEOF #18271

Closed
dsnet opened this issue Dec 9, 2016 · 1 comment
Closed

Comments

@dsnet
Copy link
Member

dsnet commented Dec 9, 2016

The documentation for io.LimitedReader says:

A LimitedReader reads from R but limits the amount of data returned to just N bytes. Each call to Read updates N to reflect the new amount remaining.

It doesn't say anything about what happens when EOF is hit first in the underlying R and N > 0. Does it return EOF or ErrUnexpectedEOF?

Current behavior is to return EOF. We should document that.

@dsnet dsnet added this to the Go1.9 milestone Dec 9, 2016
@bradfitz
Copy link
Contributor

bradfitz commented Dec 9, 2016

Well, ErrUnexpectedEOF wouldn't be the right error in any case. I think you mean EOF vs ErrUnexpectedDataNotEOFViolatingTruncatingYourData.

But yes, it's EOF, silently truncating your data at the desired location.

Feel free to send for 1.8 if you'd like, but don't re-milestone to 1.8.

@golang golang locked and limited conversation to collaborators Dec 9, 2017
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

3 participants