|
60 | 60 |
|
61 | 61 | // Variables set in Init. |
62 | 62 | var ( |
63 | | - initialized bool |
64 | 63 |
|
65 | 64 | // These are primarily used to initialize the MainModules, and should be |
66 | 65 | // eventually superseded by them but are still used in cases where the module |
@@ -406,15 +405,15 @@ func Reset() { |
406 | 405 |
|
407 | 406 | func setState(s State) State { |
408 | 407 | oldState := State{ |
409 | | - initialized: initialized, |
| 408 | + initialized: LoaderState.initialized, |
410 | 409 | forceUseModules: ForceUseModules, |
411 | 410 | rootMode: RootMode, |
412 | 411 | modRoots: modRoots, |
413 | 412 | modulesEnabled: cfg.ModulesEnabled, |
414 | 413 | mainModules: MainModules, |
415 | 414 | requirements: requirements, |
416 | 415 | } |
417 | | - initialized = s.initialized |
| 416 | + LoaderState.initialized = s.initialized |
418 | 417 | ForceUseModules = s.forceUseModules |
419 | 418 | RootMode = s.rootMode |
420 | 419 | modRoots = s.modRoots |
@@ -450,10 +449,10 @@ var LoaderState = NewState() |
450 | 449 | // configures the cfg, codehost, load, modfetch, and search packages for use |
451 | 450 | // with modules. |
452 | 451 | func Init() { |
453 | | - if initialized { |
| 452 | + if LoaderState.initialized { |
454 | 453 | return |
455 | 454 | } |
456 | | - initialized = true |
| 455 | + LoaderState.initialized = true |
457 | 456 |
|
458 | 457 | fips140.Init() |
459 | 458 |
|
@@ -573,7 +572,7 @@ func WillBeEnabled() bool { |
573 | 572 | // Already enabled. |
574 | 573 | return true |
575 | 574 | } |
576 | | - if initialized { |
| 575 | + if LoaderState.initialized { |
577 | 576 | // Initialized, not enabled. |
578 | 577 | return false |
579 | 578 | } |
@@ -640,7 +639,7 @@ func VendorDir() string { |
640 | 639 | } |
641 | 640 |
|
642 | 641 | func inWorkspaceMode() bool { |
643 | | - if !initialized { |
| 642 | + if !LoaderState.initialized { |
644 | 643 | panic("inWorkspaceMode called before modload.Init called") |
645 | 644 | } |
646 | 645 | if !Enabled() { |
@@ -1253,7 +1252,7 @@ func fixVersion(ctx context.Context, fixed *bool) modfile.VersionFixer { |
1253 | 1252 | // This function affects the default cfg.BuildMod when outside of a module, |
1254 | 1253 | // so it can only be called prior to Init. |
1255 | 1254 | func AllowMissingModuleImports() { |
1256 | | - if initialized { |
| 1255 | + if LoaderState.initialized { |
1257 | 1256 | panic("AllowMissingModuleImports after Init") |
1258 | 1257 | } |
1259 | 1258 | allowMissingModuleImports = true |
|
0 commit comments