mirror of
https://github.com/golang/go
synced 2024-11-22 02:34:40 -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:
parent
807eb29f9f
commit
51b09190ac
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user