This commit updates the Reset function to work with any state
object in preparation for converting it to a method.
This commit is part of the overall effort to eliminate global
modloader state.
Change-Id: I6103842ea0a0528698217930afc0e34a2aa21eea
Reviewed-on: https://go-review.googlesource.com/c/go/+/712701
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>
// Reset clears all the initialized, cached state about the use of modules,
// so that we can start over.
-func Reset() {
- setState(LoaderState, State{})
+func Reset(s *State) {
+ setState(s, State{})
}
func setState(s *State, new State) State {
}
// Set up modules without an explicit go.mod, to download distribution.
- modload.Reset()
+ modload.Reset(modload.LoaderState)
modload.LoaderState.ForceUseModules = true
modload.LoaderState.RootMode = modload.NoRoot
modload.Init(modload.LoaderState)
modload.LoaderState.ForceUseModules = true
modload.LoaderState.RootMode = modload.NoRoot
modload.Init(modload.LoaderState)
- defer modload.Reset()
+ defer modload.Reset(modload.LoaderState)
// See internal/load.PackagesAndErrorsOutsideModule
ctx := context.Background()