mirror of
https://github.com/teivah/100-go-mistakes.git
synced 2026-06-21 00:47:11 +08:00
context withoutCancel
This commit is contained in:
parent
77c6b74df0
commit
a88f7e476b
1 changed files with 3 additions and 0 deletions
|
|
@ -1439,6 +1439,9 @@ When the response has been written to the client, the context associated with th
|
|||
|
||||
In the latter case, calling publish will return an error because we returned the HTTP response quickly.
|
||||
|
||||
Note: From Go 1.21, there is a way to create a new context without cancel. WithoutCancel returns a copy of parent that is not canceled when parent is canceled.
|
||||
Read more [here](https://pkg.go.dev/context#WithoutCancel)
|
||||
|
||||
In summary, propagating a context should be done cautiously.
|
||||
|
||||
[Source code :simple-github:](https://github.com/teivah/100-go-mistakes/tree/master/src/09-concurrency-practice/61-inappropriate-context/main.go)
|
||||
|
|
|
|||
Loading…
Reference in a new issue