On Fri, Sep 25, 2020 at 6:36 PM Alex Besogonov <alex.besogo...@gmail.com> wrote:
>
> On Friday, September 25, 2020 at 4:43:45 PM UTC-7 Ian Lance Taylor wrote:
>>
>> On Fri, Sep 25, 2020 at 10:35 AM Alex Besogonov
>> <alex.be...@gmail.com> wrote:
>> >
>> > Inheritable goroutine-locals would actually work just fine in Go. 
>> > Moreover, Go actually has them in the form of pprof labels.
>> What should happen if one goroutine changes an inherited
>> goroutine-local variable?
>
> A Go-style goroutine-local system can be thought as a context.Context that is 
> transparently assigned to a goroutine and its children. Thus if you want to 
> change the value, you'd do something like "c := magic.GetCurrentContext(); c 
> = c.WithValue(...); magic.SetContext(c);".
>
> This would affect only the current goroutine going forward, but not its 
> children.

In general, Go's attitude is that explicit is better than implicit.
If you rigorously stick to the pattern you describe, it's the same as
passing the context.Context around explicitly (except that passing the
Context around explicitly is more flexible).

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcVJws%2BVpnYx%2BPRpRprdhvq_csti_5bwqFOnfesoKLja0A%40mail.gmail.com.

Reply via email to