Skip to content

Commit e129ac2

Browse files
committed
add comment for io.CopyBuffer
1 parent 0f897f9 commit e129ac2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/io/io.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,12 @@ func Copy(dst Writer, src Reader) (written int64, err error) {
368368
// provided buffer (if one is required) rather than allocating a
369369
// temporary one. If buf is nil, one is allocated; otherwise if it has
370370
// zero length, CopyBuffer panics.
371+
//
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 use.
371377
func CopyBuffer(dst Writer, src Reader, buf []byte) (written int64, err error) {
372378
if buf != nil && len(buf) == 0 {
373379
panic("empty buffer in io.CopyBuffer")

0 commit comments

Comments
 (0)