Skip to content

Commit 88b79fe

Browse files
committed
bufio peek better desc
bufio: the description of Peek's behavior is now clearer
1 parent d3d4e7b commit 88b79fe

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/bufio/bufio.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,11 @@ func (b *Reader) readErr() error {
132132
return err
133133
}
134134

135-
// 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.
135+
// Peek returns the next n bytes without advancing the reader. If b.Buffered() < n,
136+
// tries to read a new chunk into b's buffer. The bytes stop being valid at the
137+
// next read call. If Peek returns fewer than n bytes, it also returns an error
138+
// explaining why the read is short. The error is [ErrBufferFull] if n is larger
139+
// 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)