From 3e9013c05dfd401260a43674063a04a512dd8b15 Mon Sep 17 00:00:00 2001 From: jessemjchen Date: Tue, 28 May 2019 20:04:27 +0800 Subject: [PATCH] add comment for io.CopyBuffer --- src/io/io.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/io/io.go b/src/io/io.go index 2010770e6a428e..d37d6037b6967b 100644 --- a/src/io/io.go +++ b/src/io/io.go @@ -368,6 +368,12 @@ 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 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 use. func CopyBuffer(dst Writer, src Reader, buf []byte) (written int64, err error) { if buf != nil && len(buf) == 0 { panic("empty buffer in io.CopyBuffer")