News for hackers. Stuff that matters.
Re:Context should go away for Go 2 by Thaxll on Tuesday January 21, 2025 @03:31PM (#42784870)
Because you should wrapp that in a type safe function. You should not use the context.GetValue() directly but use your own function, the context is just a transport mechanism.
Re:Context should go away for Go 2 by kflgkans on Tuesday January 21, 2025 @04:00PM (#42785125)
If it is just a transport mechanism, why use context at all ant not a typed struct?
Re:Context should go away for Go 2 by ncruces on Tuesday January 21, 2025 @06:01PM (#42786292)
Because dozens of in between layers don't need to know the type, and should in fact work regardless of the specific type.

Context tells you enough: someone, somewhere may do magic with this if you pass it down the chain.

And in good Go tradition it's explicit about this: functions that don't take a context don't (generally) do that kind of magic.

If anything it mixes two concerns: cancelation and dynamic scoping.

But I'm not sure having two different parameters would be better.