From 1ff89009f198ad5bae3549dd3b992882bd97e5f8 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 25 May 2023 11:31:28 -0700 Subject: [PATCH] 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 --- src/io/io.go | 3 +++ 1 file changed, 3 insertions(+) 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 -- 2.50.0