Skip to content

Commit e3e1d73

Browse files
hyperion-csgopherbot
authored andcommitted
bufio: make the description of Peek's behavior better
Previously, based on the description, it was not obvious that Peek could change the buffer. It may have been mistakenly assumed that Peek would always return an error if n is greater than b.Buffered(). Change-Id: I095006dd2ba1c2138bb193396cb24e2dda42d771 GitHub-Last-Rev: 9d48f8a GitHub-Pull-Request: #70712 Reviewed-on: https://go-review.googlesource.com/c/go/+/634175 Reviewed-by: Carlos Amedee <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Jorropo <[email protected]>
1 parent e79b2e1 commit e3e1d73

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/bufio/bufio.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,10 @@ func (b *Reader) readErr() error {
133133
}
134134

135135
// Peek returns the next n bytes without advancing the reader. The bytes stop
136-
// being valid at the next read call. If Peek returns fewer than n bytes, it
137-
// also returns an error explaining why the read is short. The error is
138-
// [ErrBufferFull] if n is larger than b's buffer size.
136+
// being valid at the next read call. If necessary, Peek will read more bytes
137+
// into the buffer in order to make n bytes available. If Peek returns fewer
138+
// than n bytes, it also returns an error explaining why the read is short.
139+
// The error is [ErrBufferFull] if n is larger than b's buffer size.
139140
//
140141
// Calling Peek prevents a [Reader.UnreadByte] or [Reader.UnreadRune] call from succeeding
141142
// until the next read operation.

0 commit comments

Comments
 (0)