diff --git a/src/cmd/go/internal/modload/init.go b/src/cmd/go/internal/modload/init.go index ba88713b36e..12f52381b04 100644 --- a/src/cmd/go/internal/modload/init.go +++ b/src/cmd/go/internal/modload/init.go @@ -57,14 +57,14 @@ var ( ) // EnterModule resets MainModules and requirements to refer to just this one module. -func EnterModule(ctx context.Context, enterModroot string) { - LoaderState.MainModules = nil // reset MainModules - LoaderState.requirements = nil - LoaderState.workFilePath = "" // Force module mode +func EnterModule(loaderstate *State, ctx context.Context, enterModroot string) { + loaderstate.MainModules = nil // reset MainModules + loaderstate.requirements = nil + loaderstate.workFilePath = "" // Force module mode modfetch.Reset() - LoaderState.modRoots = []string{enterModroot} - LoadModFile(LoaderState, ctx) + loaderstate.modRoots = []string{enterModroot} + LoadModFile(loaderstate, ctx) } // EnterWorkspace enters workspace mode from module mode, applying the updated requirements to the main diff --git a/src/cmd/go/internal/workcmd/sync.go b/src/cmd/go/internal/workcmd/sync.go index 7f45909de5c..233d12986da 100644 --- a/src/cmd/go/internal/workcmd/sync.go +++ b/src/cmd/go/internal/workcmd/sync.go @@ -104,7 +104,7 @@ func runSync(ctx context.Context, cmd *base.Command, args []string) { // Use EnterModule to reset the global state in modload to be in // single-module mode using the modroot of m. - modload.EnterModule(ctx, mms.ModRoot(m)) + modload.EnterModule(modload.LoaderState, ctx, mms.ModRoot(m)) // Edit the build list in the same way that 'go get' would if we // requested the relevant module versions explicitly.