From: Ian Lance Taylor Date: Thu, 25 May 2023 18:31:28 +0000 (-0700) Subject: io: clarify that Read(nil) can return 0, EOF X-Git-Tag: go1.21rc1~211 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=1ff89009f198ad5bae3549dd3b992882bd97e5f8;p=gostls13.git io: clarify that Read(nil) can return 0, EOF Fixes #40385 Change-Id: I965b5db985fd4418a992e883073cbc8309b2cb88 Reviewed-on: https://go-review.googlesource.com/c/go/+/498355 Reviewed-by: Brad Fitzpatrick Reviewed-by: Rob Pike Run-TryBot: Ian Lance Taylor TryBot-Result: Gopher Robot Run-TryBot: Ian Lance Taylor Reviewed-by: Dmitri Shuralyov Reviewed-by: Ian Lance Taylor Auto-Submit: Ian Lance Taylor --- diff --git a/src/io/io.go b/src/io/io.go index bcb9f774f6..01f36e0ce1 100644 --- a/src/io/io.go +++ b/src/io/io.go @@ -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