|
2 | 2 | // Use of this source code is governed by a BSD-style |
3 | 3 | // license that can be found in the LICENSE file. |
4 | 4 |
|
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. |
38 | 6 | // |
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. |
41 | 8 | package context |
42 | 9 |
|
43 | 10 | import ( |
|
0 commit comments