You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to copy bytes from buffer to Stdout, however the buffer was cleared after copy. This is not a behaviour one would expect copy but rather from move. Like when you run cp src dst on linux, you do not expect src file to be cleared.
Thank you for raising this issue. Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.
The buffer tracks both its read and write positions. The string method is simply returning you a slice of the unread data. The buffer has to keep track of the last read position otherwise if someone read from the buffer a byte at a time, the position would never advance.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I tried to copy bytes from buffer to
Stdout
, however the buffer was cleared after copy. This is not a behaviour one would expect copy but rather from move. Like when you runcp src dst
on linux, you do not expect src file to be cleared.play.golang.org
What did you expect to see?
or a clear note about this behaviour in the docs.
What did you see instead?
The text was updated successfully, but these errors were encountered: