bufio: NewWriter may return a writer that is not new #49446
Labels
Documentation
Issues describing a change to documentation.
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
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 used
bufio.NewWriter
to implement theio.WriterTo
interface, passing in anotherbufio.Writer
.https://play.golang.org/p/iBz8rYK1Uae
What did you expect to see?
As defined in the documentation for
bufio.NewWriter
:The
bufio.NewWriter
call inside theWriterTo
implementation returns a newbufio.Writer
, and theWriterTo
implementation correctly calculates that it wrote 2 bytes tow
.What did you see instead?
The
bufio.NewWriter
call returns the input writer, causing theWriterTo
implementation to calculate (incorrectly) that it wrote -4094 bytes when handling an error.This behavior is properly defined on
bufio.NewWriterSize
, but notbufio.NewWriter
.The text was updated successfully, but these errors were encountered: