diff --git a/go/private/actions/stdlib.bzl b/go/private/actions/stdlib.bzl index 2ca42814ec..0069aa062b 100644 --- a/go/private/actions/stdlib.bzl +++ b/go/private/actions/stdlib.bzl @@ -92,6 +92,7 @@ def _build_stdlib_list_json(go): def _build_env(go): env = go.env + env["GOROOT"] = go.sdk.root_file.dirname if go.mode.pure: env.update({"CGO_ENABLED": "0"}) diff --git a/go/private/context.bzl b/go/private/context.bzl index c2b459f580..a86cb4c909 100644 --- a/go/private/context.bzl +++ b/go/private/context.bzl @@ -524,7 +524,6 @@ def go_context( "GOARCH": mode.goarch, "GOOS": mode.goos, "GOEXPERIMENT": toolchain.sdk.experiments, - "GOROOT": goroot, "GOROOT_FINAL": "GOROOT", "CGO_ENABLED": "0" if mode.pure else "1", diff --git a/go/tools/builders/env.go b/go/tools/builders/env.go index 2058214ecd..f1335509c4 100644 --- a/go/tools/builders/env.go +++ b/go/tools/builders/env.go @@ -87,12 +87,6 @@ func (e *env) checkFlagsAndSetGoroot() error { if e.sdk == "" { return errors.New("-sdk was not set") } - if e.goroot != "" { - err := os.Setenv("GOROOT", e.goroot) - if err != nil { - return err - } - } return nil }