Skip to content

Commit 1b541b4

Browse files
committed
io: make CopyBuffer docs state when buf is not used
Document that if either src implements the WriteTo interface or if dst implements the ReaderFrom interface, then buf will not be used. Fixes #32276
1 parent 8928a5e commit 1b541b4

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/io/io.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,8 @@ func Copy(dst Writer, src Reader) (written int64, err error) {
369369
// temporary one. If buf is nil, one is allocated; otherwise if it has
370370
// zero length, CopyBuffer panics.
371371
//
372-
// If src implements the WriterTo interface,
373-
// the copy is implemented by calling src.WriteTo(dst).
374-
// Otherwise, if dst implements the ReaderFrom interface,
375-
// the copy is implemented by calling dst.ReadFrom(src). In both cases,
376-
// buf will be ignored and will not be used.
372+
// If either src implements WriterTo or if dst implements ReaderFrom,
373+
// buf will not be used to perform the copy.
377374
func CopyBuffer(dst Writer, src Reader, buf []byte) (written int64, err error) {
378375
if buf != nil && len(buf) == 0 {
379376
panic("empty buffer in io.CopyBuffer")

0 commit comments

Comments
 (0)