]> Cypherpunks repositories - gostls13.git/commit
io: guarantee err == nil for full reads in ReadFull and ReadAtLeast
authorRuss Cox <rsc@golang.org>
Thu, 31 Jan 2013 21:46:12 +0000 (13:46 -0800)
committerRuss Cox <rsc@golang.org>
Thu, 31 Jan 2013 21:46:12 +0000 (13:46 -0800)
commit662ff5421287e3738587a9eb01fa50e080e48582
tree77c51a4bcae8a85784bf10fd2933c3bc8f3f7fa2
parent4085426f7dcfdcb7eff86fe1fd0879e02398926b
io: guarantee err == nil for full reads in ReadFull and ReadAtLeast

This is a backwards compatible API change that fixes broken code.

In Go 1.0, ReadFull(r, buf) could return either len(buf), nil or len(buf), non-nil.
Most code expects only the former, so do that and document the guarantee.

Code that was correct before is still correct.
Code that was incorrect before, by assuming the guarantee, is now correct too.

The same applies to ReadAtLeast.

Fixes #4544.

R=golang-dev, bradfitz, minux.ma
CC=golang-dev
https://golang.org/cl/7235074
src/pkg/io/io.go
src/pkg/io/io_test.go