mirror of
https://github.com/golang/go.git
synced 2025-05-18 13:54:40 +00:00
cmd/go/internal/envcmd: show GODEBUG in 'go env' output
Fixes #65777 Change-Id: I62067d8212bfd9f9475ecad036a1218ffc5c2130 GitHub-Last-Rev: a395b0293a4796e4ac5db64c1521ade4ede0dfd8 GitHub-Pull-Request: golang/go#65888 Reviewed-on: https://go-review.googlesource.com/c/go/+/566097 Reviewed-by: Bryan Mills <bcmills@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org>
This commit is contained in:
parent
2589a89468
commit
038fbf9f28
@ -104,6 +104,7 @@ func MkEnv() []cfg.EnvVar {
|
|||||||
{Name: "GOTOOLDIR", Value: build.ToolDir},
|
{Name: "GOTOOLDIR", Value: build.ToolDir},
|
||||||
{Name: "GOVCS", Value: cfg.GOVCS},
|
{Name: "GOVCS", Value: cfg.GOVCS},
|
||||||
{Name: "GOVERSION", Value: runtime.Version()},
|
{Name: "GOVERSION", Value: runtime.Version()},
|
||||||
|
{Name: "GODEBUG", Value: os.Getenv("GODEBUG")},
|
||||||
}
|
}
|
||||||
|
|
||||||
if work.GccgoBin != "" {
|
if work.GccgoBin != "" {
|
||||||
@ -530,7 +531,7 @@ func checkEnvWrite(key, val string) error {
|
|||||||
switch key {
|
switch key {
|
||||||
case "GOEXE", "GOGCCFLAGS", "GOHOSTARCH", "GOHOSTOS", "GOMOD", "GOWORK", "GOTOOLDIR", "GOVERSION":
|
case "GOEXE", "GOGCCFLAGS", "GOHOSTARCH", "GOHOSTOS", "GOMOD", "GOWORK", "GOTOOLDIR", "GOVERSION":
|
||||||
return fmt.Errorf("%s cannot be modified", key)
|
return fmt.Errorf("%s cannot be modified", key)
|
||||||
case "GOENV":
|
case "GOENV", "GODEBUG":
|
||||||
return fmt.Errorf("%s can only be set using the OS environment", key)
|
return fmt.Errorf("%s can only be set using the OS environment", key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
src/cmd/go/testdata/script/env_write.txt
vendored
6
src/cmd/go/testdata/script/env_write.txt
vendored
@ -65,14 +65,16 @@ go env -u GOPATH
|
|||||||
! stderr .+
|
! stderr .+
|
||||||
|
|
||||||
# go env -w rejects unknown or bad variables
|
# go env -w rejects unknown or bad variables
|
||||||
! go env -w GODEBUG=gctrace=1
|
! go env -w GOGC=off
|
||||||
stderr 'unknown go command variable GODEBUG'
|
stderr 'unknown go command variable GOGC'
|
||||||
! go env -w GOEXE=.bat
|
! go env -w GOEXE=.bat
|
||||||
stderr 'GOEXE cannot be modified'
|
stderr 'GOEXE cannot be modified'
|
||||||
! go env -w GOVERSION=customversion
|
! go env -w GOVERSION=customversion
|
||||||
stderr 'GOVERSION cannot be modified'
|
stderr 'GOVERSION cannot be modified'
|
||||||
! go env -w GOENV=/env
|
! go env -w GOENV=/env
|
||||||
stderr 'GOENV can only be set using the OS environment'
|
stderr 'GOENV can only be set using the OS environment'
|
||||||
|
! go env -w GODEBUG=gctrace=1
|
||||||
|
stderr 'GODEBUG can only be set using the OS environment'
|
||||||
|
|
||||||
# go env -w can set multiple variables
|
# go env -w can set multiple variables
|
||||||
env CC=
|
env CC=
|
||||||
|
Loading…
x
Reference in New Issue
Block a user