Skip to content

Commit 8c190e5

Browse files
committed
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/34249 Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 454c234 commit 8c190e5

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/io/io.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ func LimitReader(r Reader, n int64) Reader { return &LimitedReader{r, n} }
420420
// A LimitedReader reads from R but limits the amount of
421421
// data returned to just N bytes. Each call to Read
422422
// updates N to reflect the new amount remaining.
423+
// Read returns EOF when N <= 0 or when the underlying R returns EOF.
423424
type LimitedReader struct {
424425
R Reader // underlying reader
425426
N int64 // max bytes remaining

0 commit comments

Comments
 (0)