Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
net: DNS doesn't work on Windows if environment is empty? #20473
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
You're replacing the entire environment of the child process with exactly 1 environment variable pair, removing all the standard Windows environment variables. Windows things are probably not happy if they lack their entire standard environment.
You should use:
programCmd.Env = append(programCmd.Env, fmt.Sprintf("%s=%s", "SOMETHING", pwd))
I bet that fixes it.
I don't think we need to guarantee that Go programs work flawlessly in an empty environment.
changed the title
windows/http: setting environment variable for os/exec/Cmd causes http package to malfunction
May 23, 2017
programCmd.Env is set to nil at the start, so appending 1 string to it, makes your environment have 1 environment variable - and that (as @bradfitz suggested) is not acceptable under Windows - some Windows APIs use these environment variables that you delete. Try this instead: