From 424e9685bebad809ce5a0cb43d6511e79ad3a878 Mon Sep 17 00:00:00 2001 From: Andrey Abramov Date: Tue, 7 Jan 2020 20:48:28 +0300 Subject: [PATCH] Update docs on Context.Done(), Context.Deadline() and Context.Err() (#2196) Co-authored-by: Bo-Yi Wu --- context.go | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/context.go b/context.go index 9be222fc..e979d288 100644 --- a/context.go +++ b/context.go @@ -1032,26 +1032,20 @@ func (c *Context) SetAccepted(formats ...string) { /***** GOLANG.ORG/X/NET/CONTEXT *****/ /************************************/ -// Deadline returns the time when work done on behalf of this context -// should be canceled. Deadline returns ok==false when no deadline is -// set. Successive calls to Deadline return the same results. +// Deadline always returns that there is no deadline (ok==false), +// maybe you want to use Request.Context().Deadline() instead. func (c *Context) Deadline() (deadline time.Time, ok bool) { return } -// Done returns a channel that's closed when work done on behalf of this -// context should be canceled. Done may return nil if this context can -// never be canceled. Successive calls to Done return the same value. +// Done always returns nil (chan which will wait forever), +// if you want to abort your work when the connection was closed +// you should use Request.Context().Done() instead. func (c *Context) Done() <-chan struct{} { return nil } -// Err returns a non-nil error value after Done is closed, -// successive calls to Err return the same error. -// If Done is not yet closed, Err returns nil. -// If Done is closed, Err returns a non-nil error explaining why: -// Canceled if the context was canceled -// or DeadlineExceeded if the context's deadline passed. +// Err always returns nil, maybe you want to use Request.Context().Err() instead. func (c *Context) Err() error { return nil }