]> Cypherpunks repositories - gostls13.git/commit
cmd/go: use local state object in pkg `workcmd`
authorIan Alexander <jitsu@google.com>
Thu, 9 Oct 2025 00:26:24 +0000 (20:26 -0400)
committerIan Alexander <jitsu@google.com>
Sat, 25 Oct 2025 01:09:54 +0000 (18:09 -0700)
commit784700439ab9b0792bdc19fe72672d4d7171eef6
treef2e712715578b4e167fae2957f12d10b426d257d
parent69673e9be2f1724c5425d5f7240cd26d0ddba854
cmd/go: use local state object in pkg `workcmd`

This commit modifies package `workcmd` 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/workcmd
rf '
  inject modload.LoaderState runUse
  add sync.go:/func runSync\(/-0 var moduleLoaderState *modload.State
  ex {
    import "cmd/go/internal/modload";
    modload.LoaderState -> moduleLoaderState
  }
  add runSync://+0 moduleLoaderState := modload.NewState()
  add runEditwork://+0 moduleLoaderState := modload.NewState()
  add runInit://+0 moduleLoaderState := modload.NewState()
  add runUse://+0 moduleLoaderState := modload.NewState()
  add runVendor://+0 moduleLoaderState := modload.NewState()
  rm sync.go:/var moduleLoaderState \*modload.State/
'

Change-Id: Iadc4ffd19d15f80a694285c86adfc01f0d26bac7
Reviewed-on: https://go-review.googlesource.com/c/go/+/711129
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/workcmd/edit.go
src/cmd/go/internal/workcmd/init.go
src/cmd/go/internal/workcmd/sync.go
src/cmd/go/internal/workcmd/use.go
src/cmd/go/internal/workcmd/vendor.go