]> Cypherpunks repositories - gostls13.git/commit
cmd/go: use local state object in `env.runEnv`
authorIan Alexander <jitsu@google.com>
Fri, 10 Oct 2025 01:05:35 +0000 (21:05 -0400)
committerIan Alexander <jitsu@google.com>
Sat, 25 Oct 2025 01:10:22 +0000 (18:10 -0700)
commit26a8a21d7f5810cd2f33613aa17e46b38e75ec33
tree472b774b6c29b606db3e3a8b9dc9948ceff6ae23
parentf2dd3d7e316ab022e87bf56a8a2d77fd8f20c390
cmd/go: use local state object in `env.runEnv`

This commit modifies `env.runEnv` to construct a new modload.State
object using the new constructor instead of the current global
`modload.LoaderState` variable.

This commit is part of the overall effort to eliminate global
modloader state.

[git-generate]
cd src/cmd/go/internal/envcmd
rf '
  add env.go:/func runEnv\(/-0 var moduleLoaderState *modload.State
  ex {
    import "cmd/go/internal/modload";
    modload.LoaderState -> moduleLoaderState
  }
  add runEnv://+0 moduleLoaderState := modload.NewState()
  rm env.go:/var moduleLoaderState \*modload.State/
'

Change-Id: I1177df5d09a6ee642eade6cfa4278bb1629843a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/711131
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Matloob <matloob@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/cmd/go/internal/envcmd/env.go