Skip to content

Commit 07cefd8

Browse files
neildgopherbot
authored andcommitted
context: deprecate
Long superseded by the stdlib's context package. Fixes golang/go#49506 Change-Id: I16e9a1275a7370cd78d11180f608ae28ecdce143 Reviewed-on: https://go-review.googlesource.com/c/net/+/719060 Auto-Submit: Damien Neil <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Alan Donovan <[email protected]>
1 parent 5ac9dac commit 07cefd8

File tree

1 file changed

+2
-35
lines changed

1 file changed

+2
-35
lines changed

context/context.go

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,9 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
// Package context defines the Context type, which carries deadlines,
6-
// cancellation signals, and other request-scoped values across API boundaries
7-
// and between processes.
8-
// As of Go 1.7 this package is available in the standard library under the
9-
// name [context].
10-
//
11-
// Incoming requests to a server should create a [Context], and outgoing
12-
// calls to servers should accept a Context. The chain of function
13-
// calls between them must propagate the Context, optionally replacing
14-
// it with a derived Context created using [WithCancel], [WithDeadline],
15-
// [WithTimeout], or [WithValue].
16-
//
17-
// Programs that use Contexts should follow these rules to keep interfaces
18-
// consistent across packages and enable static analysis tools to check context
19-
// propagation:
20-
//
21-
// Do not store Contexts inside a struct type; instead, pass a Context
22-
// explicitly to each function that needs it. This is discussed further in
23-
// https://go.dev/blog/context-and-structs. The Context should be the first
24-
// parameter, typically named ctx:
25-
//
26-
// func DoSomething(ctx context.Context, arg Arg) error {
27-
// // ... use ctx ...
28-
// }
29-
//
30-
// Do not pass a nil [Context], even if a function permits it. Pass [context.TODO]
31-
// if you are unsure about which Context to use.
32-
//
33-
// Use context Values only for request-scoped data that transits processes and
34-
// APIs, not for passing optional parameters to functions.
35-
//
36-
// The same Context may be passed to functions running in different goroutines;
37-
// Contexts are safe for simultaneous use by multiple goroutines.
5+
// Package context has been superseded by the standard library [context] package.
386
//
39-
// See https://go.dev/blog/context for example code for a server that uses
40-
// Contexts.
7+
// Deprecated: Use the standard library context package instead.
418
package context
429

4310
import (

0 commit comments

Comments
 (0)