Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bytes: Buffer.ReadBytes() does not advance the buffer #1498

Closed
gopherbot opened this issue Feb 11, 2011 · 3 comments
Closed

bytes: Buffer.ReadBytes() does not advance the buffer #1498

gopherbot opened this issue Feb 11, 2011 · 3 comments

Comments

@gopherbot
Copy link

by joelegasse:

What steps will reproduce the problem?

Compiling and running the following program:

package main

import (
  "fmt"
  "bytes"
)

func main() {
  buf := bytes.NewBuffer([]byte{1, 2, 3, 4, 5})
  buf.ReadBytes(3)
  next,_ := buf.ReadByte()
  fmt.Println(next)
} 

What is the expected output?

"4" should be printed

What do you see instead?

"1" is printed

Which compiler are you using (5g, 6g, 8g, gccgo)?

6g

Which operating system are you using?

linux


Which revision are you using?  (hg identify)

867d37fb41a4 release.2011-02-01.1/release


Please provide any additional information below.

in src/pkg/bytes/buffer.go, right before the return for ReadBytes(), there should be the
line:

  b.off += size
@rsc
Copy link
Contributor

rsc commented Feb 11, 2011

Comment 1:

Code review to fix this in progress:
http://golang.org/cl/4140041/

Owner changed to r...@golang.org.

Status changed to Started.

@rsc
Copy link
Contributor

rsc commented Feb 11, 2011

Comment 2:

Issue #1499 has been merged into this issue.

@rsc
Copy link
Contributor

rsc commented Feb 11, 2011

Comment 3:

This issue was closed by revision bbfad5f.

Status changed to Fixed.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc unassigned robpike Jun 22, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants