mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
internal/godebug: remove dependency on os
The immediate reason is that we want to use godebug from math/rand, and math/rand importing godebug importing os causes an import cycle in package testing. More generally, the new approach to backward compatibility outlined in discussion #55090 will require using this package from other similarly sensitive places, perhaps even package os itself. Best to remove all dependencies. Preparation for #54880. Change-Id: Ia01657a2d90e707a8121a336c9db3b7247c0198f Reviewed-on: https://go-review.googlesource.com/c/go/+/439418 Auto-Submit: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
9fedc481ea
commit
8dc08394f0
10 changed files with 72 additions and 28 deletions
|
|
@ -5,11 +5,14 @@
|
|||
// Package godebug parses the GODEBUG environment variable.
|
||||
package godebug
|
||||
|
||||
import "os"
|
||||
import _ "unsafe" // go:linkname
|
||||
|
||||
//go:linkname getGODEBUG
|
||||
func getGODEBUG() string
|
||||
|
||||
// Get returns the value for the provided GODEBUG key.
|
||||
func Get(key string) string {
|
||||
return get(os.Getenv("GODEBUG"), key)
|
||||
return get(getGODEBUG(), key)
|
||||
}
|
||||
|
||||
// get returns the value part of key=value in s (a GODEBUG value).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue