Update docs on Context.Done(), Context.Deadline() and Context.Err() (#2196)

Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Andrey Abramov 2020-01-07 20:48:28 +03:00 committed by thinkerou
parent 025950afe9
commit 424e9685be

View File

@ -1032,26 +1032,20 @@ func (c *Context) SetAccepted(formats ...string) {
/***** GOLANG.ORG/X/NET/CONTEXT *****/ /***** GOLANG.ORG/X/NET/CONTEXT *****/
/************************************/ /************************************/
// Deadline returns the time when work done on behalf of this context // Deadline always returns that there is no deadline (ok==false),
// should be canceled. Deadline returns ok==false when no deadline is // maybe you want to use Request.Context().Deadline() instead.
// set. Successive calls to Deadline return the same results.
func (c *Context) Deadline() (deadline time.Time, ok bool) { func (c *Context) Deadline() (deadline time.Time, ok bool) {
return return
} }
// Done returns a channel that's closed when work done on behalf of this // Done always returns nil (chan which will wait forever),
// context should be canceled. Done may return nil if this context can // if you want to abort your work when the connection was closed
// never be canceled. Successive calls to Done return the same value. // you should use Request.Context().Done() instead.
func (c *Context) Done() <-chan struct{} { func (c *Context) Done() <-chan struct{} {
return nil return nil
} }
// Err returns a non-nil error value after Done is closed, // Err always returns nil, maybe you want to use Request.Context().Err() instead.
// 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.
func (c *Context) Err() error { func (c *Context) Err() error {
return nil return nil
} }