mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/go: convert functions to methods
This commit converts the Reset and setState functions to methods. This commit is part of the overall effort to eliminate global modloader state. [git-generate] cd src/cmd/go/internal/modload rf ' mv setState State.setState mv Reset State.Reset ' Change-Id: Ibc40071dc044ef5d1ab0a0b03f17b75243a42011 Reviewed-on: https://go-review.googlesource.com/c/go/+/712702 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Michael Matloob <matloob@google.com>
This commit is contained in:
parent
0d3044f965
commit
bcf7da1595
2 changed files with 7 additions and 7 deletions
|
|
@ -81,7 +81,7 @@ func EnterWorkspace(ctx context.Context) (exit func(), err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset the state to a clean state.
|
// Reset the state to a clean state.
|
||||||
oldstate := setState(LoaderState, State{})
|
oldstate := LoaderState.setState(State{})
|
||||||
LoaderState.ForceUseModules = true
|
LoaderState.ForceUseModules = true
|
||||||
|
|
||||||
// Load in workspace mode.
|
// Load in workspace mode.
|
||||||
|
|
@ -93,7 +93,7 @@ func EnterWorkspace(ctx context.Context) (exit func(), err error) {
|
||||||
LoaderState.requirements = requirementsFromModFiles(LoaderState, ctx, LoaderState.MainModules.workFile, slices.Collect(maps.Values(LoaderState.MainModules.modFiles)), nil)
|
LoaderState.requirements = requirementsFromModFiles(LoaderState, ctx, LoaderState.MainModules.workFile, slices.Collect(maps.Values(LoaderState.MainModules.modFiles)), nil)
|
||||||
|
|
||||||
return func() {
|
return func() {
|
||||||
setState(LoaderState, oldstate)
|
LoaderState.setState(oldstate)
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -377,11 +377,11 @@ func WorkFilePath(loaderstate *State) string {
|
||||||
|
|
||||||
// Reset clears all the initialized, cached state about the use of modules,
|
// Reset clears all the initialized, cached state about the use of modules,
|
||||||
// so that we can start over.
|
// so that we can start over.
|
||||||
func Reset(s *State) {
|
func (s *State) Reset() {
|
||||||
setState(s, State{})
|
s.setState(State{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func setState(s *State, new State) State {
|
func (s *State) setState(new State) State {
|
||||||
oldState := State{
|
oldState := State{
|
||||||
initialized: s.initialized,
|
initialized: s.initialized,
|
||||||
ForceUseModules: s.ForceUseModules,
|
ForceUseModules: s.ForceUseModules,
|
||||||
|
|
|
||||||
|
|
@ -352,7 +352,7 @@ func Exec(gotoolchain string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up modules without an explicit go.mod, to download distribution.
|
// Set up modules without an explicit go.mod, to download distribution.
|
||||||
modload.Reset(modload.LoaderState)
|
modload.LoaderState.Reset()
|
||||||
modload.LoaderState.ForceUseModules = true
|
modload.LoaderState.ForceUseModules = true
|
||||||
modload.LoaderState.RootMode = modload.NoRoot
|
modload.LoaderState.RootMode = modload.NoRoot
|
||||||
modload.Init(modload.LoaderState)
|
modload.Init(modload.LoaderState)
|
||||||
|
|
@ -695,7 +695,7 @@ func maybeSwitchForGoInstallVersion(minVers string) {
|
||||||
modload.LoaderState.ForceUseModules = true
|
modload.LoaderState.ForceUseModules = true
|
||||||
modload.LoaderState.RootMode = modload.NoRoot
|
modload.LoaderState.RootMode = modload.NoRoot
|
||||||
modload.Init(modload.LoaderState)
|
modload.Init(modload.LoaderState)
|
||||||
defer modload.Reset(modload.LoaderState)
|
defer modload.LoaderState.Reset()
|
||||||
|
|
||||||
// See internal/load.PackagesAndErrorsOutsideModule
|
// See internal/load.PackagesAndErrorsOutsideModule
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue