4 ms·
The post is right about the problems with the context object, but is flat wrong when it claims that the only problem it solves is cancelation. Cancelation is j
by adrianratnapala 9y ago
The post is right about the problems with the context object, but is flat wrong when it claims that the only problem it solves is cancelation.
Cancelation is just one aspect of a generic concern: that a tree of function calls (and more importantly, RPCs) is a causal chain of events that external systems (including humans) will want to monitor and control. Trace IDs, auth tokens and other things need to be propagated somehow, but the code that they propagate through shouldn't care about them.
So its nice to have context.Context in the standard library so that we don't have a proliferation of per-library hand-rolled solutions which then have to be virally propagated.