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
cmd/go: setting the User or System Environment Variables #30190
Comments
Please tell us what you did exactly. |
I was trying to set the environment variables from the Go program. |
Please provide a concrete list of commands that we can run to reproduce the problem, along with the output you observed from those commands. |
package main import ( func main(){ |
Can you show us the output you are getting ? I am failing to reproduce the issue here. |
The code works fine. But when I check for the CGO_LDFLAGS in user or system variables, I did not find it. |
If you want to set the user or system variables you need admin permissions and you need the Windows API. |
Can we set it from exec.Command() function? |
I have created a package when the user does go get command, I want a go file to run automatically so that it can set environmental variables. Can we run a file in golang when the user downloads the package? |
You can try the As this is not a bug, I suggest you ask for further help in one of the places listed in https://github.com/golang/go/wiki/Questions Or maybe even https://social.msdn.microsoft.com/Forums/en-US/home
No, if you want that you need to make your own downloader/installer |
If we create a package in node we can do that if the user downloads a package using npm. (Run a file after package gets downloaded) Is it a backlog in golang? |
This was raised before and closed. Please see #15536. Specifically this comment -
If you think you have a use case which might be beneficial to others, please feel free to open a proposal issue laying out the requirements and your proposed outline. Please note that there are other places too where Go differs from npm style package install. For eg- there is no concept of It sounds like the current issue is resolved anyways. So closing this. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
NO
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
package main
import (
"fmt"
"os"
"path"
)
func main(){
a := os.Getenv("GOPATH")
base := path.Join(a,"/src/github.com/ibmdb/go_ibm_db")
fmt.Println(base)
os.Setenv("CGO_LDFLAGS",base)
fmt.Println(os.Getenv("CGO_LDFLAGS"))
}
What did you expect to see?
CGO_LDFLAGS will be updated.
What did you see instead?
Nothing has been changed in that Env Variable
The text was updated successfully, but these errors were encountered: