-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runtime: cgo can't set new environment variables for Go #44108
Comments
given that |
@seankhliao I don't think the problem is with
Here’s how to run the code to repro the issue. Notice the missing value for NEW_VAR when accessed via Go’s os package.
|
I see, I think it's related to #27693 but not sure if it's the same issue |
I agree, this is similar to #27693. The only difference is that in #27693, C.setenv after Go runtime is setup while in this case it is being called before Go runtime is setup. It is ok to not support the former because C.setenv isn't thread-safe. Looking at the Go runtime setup code, it gets the environment from the arguments to C main. If instead Go runtime setup code get the environment from |
I think it's OK for us to just say that the behavior here is implementation defined. Especially when we start considering the behavior with For what it's worth, this is what I see for the first program:
|
Thanks @ianlancetaylor. |
Closing as working as intended |
What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Here is the source code (also on playground does not work https://play.golang.org/p/knyUM81kREi)
What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: