]> Cypherpunks repositories - gostls13.git/commit
cmd/go: inject state parameter into `fmtcmd.runFmt`
authorIan Alexander <jitsu@google.com>
Fri, 3 Oct 2025 19:04:30 +0000 (15:04 -0400)
committerIan Alexander <jitsu@google.com>
Mon, 20 Oct 2025 19:50:38 +0000 (12:50 -0700)
commit29a81624f744f0435925cb7c349f68c86213f09c
treeade418d4d8e02e5110e35574b81269923b278625
parentf7eaea02fd8a5d1d37f023a1144e747da0b3dd7b
cmd/go: inject state parameter into `fmtcmd.runFmt`

This command modifies the call tree starting at `fmtcmd.runFmt` to
inject a `State` parameter to every function that is currently using
the global `modload.LoaderState` variable.  By explicilty passing a
`State` parameter, we can begin to eliminate the usage of the global
`modload.LoaderState`.

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

[git-generate]
cd src/cmd/go/internal/fmtcmd
rf '
  inject modload.LoaderState runFmt
  add fmt.go var moduleLoaderState *modload.State
  ex {
    import "cmd/go/internal/modload";
    modload.LoaderState -> moduleLoaderState
  }
  add runFmt://+0 moduleLoaderState := modload.NewState()
  rm fmt.go:/var moduleLoaderState \*modload.State/
'
cd ..
./rf-cleanup.zsh

Change-Id: Ib6692aba37a2cbc5b52d3bb705ec2b442afd26eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/709989
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/fmtcmd/fmt.go