On Mon, Aug 5, 2019 at 9:20 AM B Carr <buc...@gmail.com> wrote:
>
>
>
> On Monday, August 5, 2019 at 8:52:41 AM UTC-6, burak serdar wrote:
>>
>> On Mon, Aug 5, 2019 at 8:47 AM B Carr <buc...@gmail.com> wrote:
>> >
>> > Is it safe to say that environment variables (accessible to all 
>> > goroutines) also live in the data segment?
>>
>> No.
>>
>> When you say "environment variables", do you mean OS env variables, or
>> the variables visible to a goroutine?
>>
>> If you're talking about the variables visible to a goroutine, where
>> the variable lives depends on how it is declared and allocated.
>>
>> If the variable is allocated at compile time (like a global var/struct
>> initialized with a literal) it lives in data segment.
>>
>> If the variable is allocated dynamically using new(), or it is
>> declared in a function and it escapes, it lives on the heap.
>
>
> Oh. I'm talking about env variables which a goroutine sets by using 
> os.Setenv() which to me implies OS env variables. Are those env variables 
> accessible by all goroutines regardless of which goroutine set the env 
> variable? Would such env variables be available to newer goroutines that spin 
> up? I think the answer to this is "Yes", based on a response I got to another 
> thread.

Those env variables belong to the process. All gorountines share them.
If you're setting env variables from goroutines, you might want to
think about thread safety of setenv.


>
> I'm apparently being too black/white in my thinking about where things get 
> put into memory and your explanations are helping to get my mind right.
>
> --
> 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/e064b3a9-19f1-48ca-8fab-e438a737b889%40googlegroups.com.

-- 
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/CAMV2RqpoMgOxGtVEHUmpKva%3D7nJHvANOUSW5uWHUDAg%2BvZC-ow%40mail.gmail.com.

Reply via email to