aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/binary/binary.go
diff options
context:
space:
mode:
authorJoe Tsai <joetsai@digital-static.net>2015-09-30 13:35:03 -0700
committerBrad Fitzpatrick <bradfitz@golang.org>2015-09-30 22:10:44 +0000
commitb72a4a07c257f394f5a96dff29a4fc862601a41f (patch)
tree6579657426318980ebc3d3276d2b3ab151a1bc30 /src/encoding/binary/binary.go
parente01be84149b8189a58815ab75a86984e58d203e2 (diff)
downloadgo-b72a4a07c257f394f5a96dff29a4fc862601a41f.tar.xz
encoding/binary: document that Read returns io.EOF iff zero bytes are read
Also add a unit test to lock this behavior into the API. Fixes #12016 Change-Id: Ib6ec6e7948f0705f3504ede9143b5dc4e790fc44 Reviewed-on: https://go-review.googlesource.com/15171 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/encoding/binary/binary.go')
-rw-r--r--src/encoding/binary/binary.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/encoding/binary/binary.go b/src/encoding/binary/binary.go
index 2bbe07c02f..1c2577b68d 100644
--- a/src/encoding/binary/binary.go
+++ b/src/encoding/binary/binary.go
@@ -135,6 +135,10 @@ func (bigEndian) GoString() string { return "binary.BigEndian" }
// blank (_) field names is skipped; i.e., blank field names
// may be used for padding.
// When reading into a struct, all non-blank fields must be exported.
+//
+// The error is EOF only if no bytes were read.
+// If an EOF happens after reading some but not all the bytes,
+// Read returns ErrUnexpectedEOF.
func Read(r io.Reader, order ByteOrder, data interface{}) error {
// Fast path for basic types and slices.
if n := intDataSize(data); n != 0 {