This test is verifying that setting or unsetting an environment variable in Go via the "os" package makes that change visible to the C getenv function. The test has been failing on Windows since CL 304569; it isn't clear to me whether it was running at all before that point. On Windows the getenv and _putenv C functions are not thread-safe, so Go's os.Setenv and os.Getenv use the SetEnvironmentVariable and GetEnvironmentVariable system calls instead. That seems to work fine in practice; however, changes via SetEnvironmentVariable are empirically not visible to the C getenv function on certain versions of Windows. The MSDN getenv documentation¹ states that ‘getenv operates only on the data structures accessible to the run-time library and not on the environment “segment” created for the process by the operating system. Therefore, programs that use the envp argument to main or wmain may retrieve invalid information.’ That may be related to what we're seeing here. (https://github.com/curl/curl/issues/4774 describes this same behavior observed in the curl project.) ¹https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/getenv-wgetenv?view=msvc-160#remarks Updates #36705 Change-Id: I222792f75c650f32c5025b0fa3edab232ff66353 Reviewed-on: https://go-review.googlesource.com/c/go/+/304669 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> |
||
|---|---|---|
| .github | ||
| api | ||
| doc | ||
| lib/time | ||
| misc | ||
| src | ||
| test | ||
| .gitattributes | ||
| .gitignore | ||
| AUTHORS | ||
| CONTRIBUTING.md | ||
| CONTRIBUTORS | ||
| LICENSE | ||
| PATENTS | ||
| README.md | ||
| SECURITY.md | ||
| codereview.cfg | ||
README.md
The Go Programming Language
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
Gopher image by Renee French, licensed under Creative Commons 3.0 Attributions license.
Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.
Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.
Download and Install
Binary Distributions
Official binary distributions are available at https://golang.org/dl/.
After downloading a binary release, visit https://golang.org/doc/install for installation instructions.
Install From Source
If a binary distribution is not available for your combination of operating system and architecture, visit https://golang.org/doc/install/source for source installation instructions.
Contributing
Go is the work of thousands of contributors. We appreciate your help!
To contribute, please read the contribution guidelines at https://golang.org/doc/contribute.html.
Note that the Go project uses the issue tracker for bug reports and proposals only. See https://golang.org/wiki/Questions for a list of places to ask questions about the Go language.