-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
Milestone
Description
Before filing a bug, please check whether it has been fixed since
the latest release: run "hg pull", "hg update default", rebuild, and
retry
what you did to
reproduce the problem. Thanks.
What steps will reproduce the problem?
package main
import (
"io"
"fmt"
"bufio"
)
type testReader struct {}
func (r *testReader) Read(p []byte) (int, error) {
return copy(p, "abcd"), io.EOF
}
func main() {
buf := bufio.NewReaderSize(new(testReader), 32)
s, err := buf.Peek(2)
fmt.Println(string(s),err)
}
What is the expected output?
ab <nil>
What do you see instead?
ab EOF
Which compiler are you using (5g, 6g, 8g, gccgo)?
8g
Which operating system are you using?
linux
Which revision are you using? (hg identify)
e01251826b3a tip
Please provide any additional information below.
The last if clause in the Peek function will always be false.
In the case that an error is returned, should it use
b.err instead or b.readErr()? Otherwise it will eat the
error and it wont be available for next Read call.Reactions are currently unavailable