From 03978a97e5336c0ef46cec9b4f0733e9d897d083 Mon Sep 17 00:00:00 2001 From: sandyskies Date: Mon, 21 Oct 2019 17:32:13 +0000 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 #32276 Change-Id: Id0a69c90e255e694e7ec9f79ffe4d8391441e59e GitHub-Last-Rev: 750e7e86d5d9b985fae7f2329fd219cacf72a62b GitHub-Pull-Request: golang/go#32279 Reviewed-on: https://go-review.googlesource.com/c/go/+/179137 Reviewed-by: Emmanuel Odeke --- src/io/io.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/io/io.go b/src/io/io.go index 2010770e6a..9cc3086c19 100644 --- a/src/io/io.go +++ b/src/io/io.go @@ -368,6 +368,9 @@ func Copy(dst Writer, src Reader) (written int64, err error) { // provided buffer (if one is required) rather than allocating a // temporary one. If buf is nil, one is allocated; otherwise if it has // zero length, CopyBuffer panics. +// +// If either src implements WriterTo or 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")