From 1b541b4bf2fbaf9dbd28d09eef4e3f93d3c394ef Mon Sep 17 00:00:00 2001 From: sandyskies Date: Sun, 20 Oct 2019 23:08:24 +0800 Subject: [PATCH] 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 https://github.com/golang/go/issues/32276 --- src/io/io.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/io/io.go b/src/io/io.go index a65f33ba6e..7c3539ac88 100644 --- a/src/io/io.go +++ b/src/io/io.go @@ -369,11 +369,8 @@ func Copy(dst Writer, src Reader) (written int64, err error) { // temporary one. If buf is nil, one is allocated; otherwise if it has // zero length, CopyBuffer panics. // -// If src implements the WriterTo interface, -// the copy is implemented by calling src.WriteTo(dst). -// Otherwise, if dst implements the ReaderFrom interface, -// the copy is implemented by calling dst.ReadFrom(src). In both cases, -// buf will be ignored and will not be used. +// If either src implements WriterTo or if dst implements ReaderFrom, +// buf will not be used to perform the copy. func CopyBuffer(dst Writer, src Reader, buf []byte) (written int64, err error) { if buf != nil && len(buf) == 0 { panic("empty buffer in io.CopyBuffer")