mirror of https://github.com/golang/go.git
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
This commit is contained in:
parent
8928a5efe1
commit
1b541b4bf2
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Reference in New Issue