Re:Don't setenv in multi-threaded code on glibc
by bonzini on Wednesday February 01, 2017 @03:15AM
(#13539213)
But Go's Setenv calls setenv_c, so a rogue C getenv would still be able to provoke races in Go code. Yes, a rogue C setenv would not provoke races in Go code calling getenv, but C interoperability is busted anyway---that's why I said that the mutex is the important part. It would work just as well (excluding cgo) if Go getenv called C getenv.
They don't use getenv because it does a slow linear search, while Go can use a more efficient string->string map.
They don't use getenv because it does a slow linear search, while Go can use a more efficient string->string map.