]> Cypherpunks repositories - gostls13.git/commitdiff
io: clarify that Read(nil) can return 0, EOF
authorIan Lance Taylor <iant@golang.org>
Thu, 25 May 2023 18:31:28 +0000 (11:31 -0700)
committerGopher Robot <gobot@golang.org>
Fri, 26 May 2023 17:03:12 +0000 (17:03 +0000)
Fixes #40385

Change-Id: I965b5db985fd4418a992e883073cbc8309b2cb88
Reviewed-on: https://go-review.googlesource.com/c/go/+/498355
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

src/io/io.go

index bcb9f774f625be46e5be3e44044c63c73d5b56e1..01f36e0ce133b7fe7083858b712fc90343133dfe 100644 (file)
@@ -74,6 +74,9 @@ var ErrNoProgress = errors.New("multiple Read calls return no data or error")
 // that happen after reading some bytes and also both of the
 // allowed EOF behaviors.
 //
+// If len(p) == 0, Read should always return n == 0. It may return a
+// non-nil error if some error condition is known, such as EOF.
+//
 // Implementations of Read are discouraged from returning a
 // zero byte count with a nil error, except when len(p) == 0.
 // Callers should treat a return of 0 and nil as indicating that