io: Copy reports ErrShortWrite for long writes #39978
Labels
FrozenDueToAge
help wanted
NeedsFix
The path to resolution is known, but the work has not been done.
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 implemented a buggy io.Writer which sometimes writes too many bytes (i.e., more that the length of the []byte parameter to the Write method), and used io.Copy to write to it.
https://play.golang.org/p/UeO1GCEvmNP
What did you expect to see?
A reasonable error message (indicating that the wrong number of bytes were written, or too many bytes were written)
What did you see instead?
ErrShortWrite.
Based on the documented meaning of this error variable, I believe io.Copy is using it incorrectly in this case.
For what it's worth, this came up while debugging real code: the Writer in question buffers writes and was buggy.
The text was updated successfully, but these errors were encountered: