From: Brad Fitzpatrick Date: Wed, 16 Apr 2014 00:14:03 +0000 (-0700) Subject: io: document that a Writer must not write to p X-Git-Tag: go1.3beta1~69 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a1ae3a05363050dc4bd809c367ba764b5d11e811;p=gostls13.git io: document that a Writer must not write to p Per golang-nuts question. Writing to p breaks other writers (e.g. io.MultiWriter). Make this explicit. LGTM=gri, r, rsc R=r, rsc, gri, joshlf13 CC=golang-codereviews https://golang.org/cl/87780046 --- diff --git a/src/pkg/io/io.go b/src/pkg/io/io.go index f7073ffc06..022fdb6764 100644 --- a/src/pkg/io/io.go +++ b/src/pkg/io/io.go @@ -74,6 +74,7 @@ type Reader interface { // It returns the number of bytes written from p (0 <= n <= len(p)) // and any error encountered that caused the write to stop early. // Write must return a non-nil error if it returns n < len(p). +// Write must not modify the slice data, even temporarily. type Writer interface { Write(p []byte) (n int, err error) }