1
0
mirror of https://github.com/golang/go synced 2024-11-25 15:17:58 -07:00

io/ioutil: add a comment on why devNull is a ReaderFrom

... protects this optimization from future well-meaning
Gophers looking to delete unused code. :)

R=gri
CC=golang-dev
https://golang.org/cl/5165041
This commit is contained in:
Brad Fitzpatrick 2011-09-29 15:35:01 -07:00
parent 807eb29f9f
commit 51b09190ac

View File

@ -104,6 +104,10 @@ func NopCloser(r io.Reader) io.ReadCloser {
type devNull int
// devNull implements ReaderFrom as an optimization so io.Copy to
// ioutil.Discard can avoid doing unnecessary work.
var _ io.ReaderFrom = devNull(0)
func (devNull) Write(p []byte) (int, os.Error) {
return len(p), nil
}