Commit 8c190e58 authored by Joe Tsai's avatar Joe Tsai Committed by Joe Tsai

io: update documentation on LimitedReader

Specify that that LimitedReader returns EOF when the underlying
R returns EOF even if bytes remaining, N > 0.

Fixes #18271

Change-Id: I990a7135f1d31488d535238ae061d42ee96bacb7
Reviewed-on: https://go-review.googlesource.com/34249Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 454c2343
...@@ -420,6 +420,7 @@ func LimitReader(r Reader, n int64) Reader { return &LimitedReader{r, n} } ...@@ -420,6 +420,7 @@ func LimitReader(r Reader, n int64) Reader { return &LimitedReader{r, n} }
// A LimitedReader reads from R but limits the amount of // A LimitedReader reads from R but limits the amount of
// data returned to just N bytes. Each call to Read // data returned to just N bytes. Each call to Read
// updates N to reflect the new amount remaining. // updates N to reflect the new amount remaining.
// Read returns EOF when N <= 0 or when the underlying R returns EOF.
type LimitedReader struct { type LimitedReader struct {
R Reader // underlying reader R Reader // underlying reader
N int64 // max bytes remaining N int64 // max bytes remaining
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment