Commit 03978a97 authored by sandyskies's avatar sandyskies Committed by Emmanuel Odeke

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/+/179137Reviewed-by: default avatarEmmanuel Odeke <emm.odeke@gmail.com>
parent 58b03194
...@@ -368,6 +368,9 @@ func Copy(dst Writer, src Reader) (written int64, err error) { ...@@ -368,6 +368,9 @@ func Copy(dst Writer, src Reader) (written int64, err error) {
// provided buffer (if one is required) rather than allocating a // provided buffer (if one is required) rather than allocating a
// temporary one. If buf is nil, one is allocated; otherwise if it has // temporary one. If buf is nil, one is allocated; otherwise if it has
// zero length, CopyBuffer panics. // 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) { func CopyBuffer(dst Writer, src Reader, buf []byte) (written int64, err error) {
if buf != nil && len(buf) == 0 { if buf != nil && len(buf) == 0 {
panic("empty buffer in io.CopyBuffer") panic("empty buffer in io.CopyBuffer")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment