diff --git a/src/runtime/env_test.go b/src/runtime/env_test.go index 203f38065d5f6d..2399e46faa91e8 100644 --- a/src/runtime/env_test.go +++ b/src/runtime/env_test.go @@ -15,6 +15,12 @@ func TestFixedGOROOT(t *testing.T) { t.Skipf("skipping plan9, it is inconsistent by allowing GOROOT to be updated by Setenv") } + // Restore both the real GOROOT environment variable, and runtime's copies: + if orig, ok := syscall.Getenv("GOROOT"); ok { + defer syscall.Setenv("GOROOT", orig) + } else { + defer syscall.Unsetenv("GOROOT") + } envs := runtime.Envs() oldenvs := append([]string{}, envs...) defer runtime.SetEnvs(oldenvs)