]> Cypherpunks repositories - gostls13.git/commit
cmd/go: inject state parameter into `clean.runClean`
authorIan Alexander <jitsu@google.com>
Wed, 8 Oct 2025 16:07:44 +0000 (12:07 -0400)
committerIan Alexander <jitsu@google.com>
Mon, 20 Oct 2025 19:50:25 +0000 (12:50 -0700)
commitf7eaea02fd8a5d1d37f023a1144e747da0b3dd7b
treeb75f6f0a78ab0ff1aac405dd93106638788d64c7
parent58a8fdb6cf4a905fd3de44bf2dd87d14fbd38dfe
cmd/go: inject state parameter into `clean.runClean`

This command modifies the call tree starting at `clean.runClean` 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/clean
rf '
  inject modload.LoaderState runClean
  add clean.go var moduleLoaderState *modload.State
  ex {
    import "cmd/go/internal/modload";
    modload.LoaderState -> moduleLoaderState
  }
  add runClean://+0 moduleLoaderState := modload.NewState()
  rm clean.go:/var moduleLoaderState \*modload.State/
'
cd ..
./rf-cleanup.zsh

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