Closed
Description
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version
)?
go version go1.7.3 linux/amd64
What operating system and processor architecture are you using (go env
)?
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/mgarton/gopath"
GORACE=""
GOROOT="/home/mgarton/go"
GOTOOLDIR="/home/mgarton/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build323320002=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
What did you do?
I ran this:
func TestPeekAndUnread(t *testing.T) {
message := []byte("hello world. how are you?")
br := bufio.NewReaderSize(bytes.NewReader(message), 16)
for i := 0; i < 16; i++ {
_, _, err := br.ReadRune()
if err != nil {
t.Fatal(err)
}
}
_, err := br.Peek(1)
if err != nil {
t.Fatal(err)
}
err = br.UnreadRune()
if err != nil {
t.Error(err)
}
}
What did you expect to see?
Either the test should pass, or the documentation for bufio.Reader.UnreadRune should mention that Peek can prevent UnreadRune from working.
What did you see instead?
The test fails.
If someone tells me whether this is a code bug or a documentation issue, I'm happy to attempt a CL