]> Cypherpunks repositories - gostls13.git/commit
cmd/go: use local state object in work.runBuild and work.runInstall
authorIan Alexander <jitsu@google.com>
Fri, 10 Oct 2025 02:08:58 +0000 (22:08 -0400)
committerIan Alexander <jitsu@google.com>
Sat, 25 Oct 2025 13:33:03 +0000 (06:33 -0700)
commit12ec09f434dca930b7dbd76c6edbcd9b4457f2f0
treed27f4412721630af4862b3fea26c4983f1ee50eb
parent643f80a11f76ada6323bdcbc36add24832f5821b
cmd/go: use local state object in work.runBuild and work.runInstall

This commit modifies `runBuild` and `runInstall` 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/work
rf '
  add build.go:/func runBuild\(/-0 var moduleLoaderState *modload.State
  ex {
    import "cmd/go/internal/modload";
    modload.LoaderState -> moduleLoaderState
  }
  add runBuild://+0 moduleLoaderState := modload.NewState()
  add runInstall://+0 moduleLoaderState := modload.NewState()
  rm build.go:/var moduleLoaderState \*modload.State/
'

Change-Id: I1137e0b898a5bda8697dce8713f96f238ae8b76c
Reviewed-on: https://go-review.googlesource.com/c/go/+/711135
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/work/build.go