Grokking Concurrency in Go
0% completed
Rules for Using Context
The documentation of the context package contains a short list of rules, and its first rule reads:
Do not store Contexts inside a struct type; instead, pass a Context explicitly to each function that needs it.
The rules matter because a context works only when every function in a chain follows them. A function can drop the context, store it in the wrong place, or ignore its Done channel. Any of these means that the functions it calls are never told to stop, and nothing fails at compile time.
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%