// Variables set in Init.
var (
- initialized bool
// These are primarily used to initialize the MainModules, and should be
// eventually superseded by them but are still used in cases where the module
func setState(s State) State {
oldState := State{
- initialized: initialized,
+ initialized: LoaderState.initialized,
forceUseModules: ForceUseModules,
rootMode: RootMode,
modRoots: modRoots,
mainModules: MainModules,
requirements: requirements,
}
- initialized = s.initialized
+ LoaderState.initialized = s.initialized
ForceUseModules = s.forceUseModules
RootMode = s.rootMode
modRoots = s.modRoots
// configures the cfg, codehost, load, modfetch, and search packages for use
// with modules.
func Init() {
- if initialized {
+ if LoaderState.initialized {
return
}
- initialized = true
+ LoaderState.initialized = true
fips140.Init()
// Already enabled.
return true
}
- if initialized {
+ if LoaderState.initialized {
// Initialized, not enabled.
return false
}
}
func inWorkspaceMode() bool {
- if !initialized {
+ if !LoaderState.initialized {
panic("inWorkspaceMode called before modload.Init called")
}
if !Enabled() {
// This function affects the default cfg.BuildMod when outside of a module,
// so it can only be called prior to Init.
func AllowMissingModuleImports() {
- if initialized {
+ if LoaderState.initialized {
panic("AllowMissingModuleImports after Init")
}
allowMissingModuleImports = true