{"record":{"id":"62d5febda608bdb3","repo":"kataras/iris","slug":"nil-loader","errorCode":null,"errorMessage":"nil loader","messagePattern":"nil loader","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"i18n/i18n.go","lineNumber":190,"sourceCode":"\ti.loader = loader\n\ti.matcher = &Matcher{\n\t\tstrict:             len(tags) > 0,\n\t\tLanguages:          tags,\n\t\tmatcher:            language.NewMatcher(tags),\n\t\tdefaultMessageFunc: i.DefaultMessageFunc,\n\t}\n\n\treturn i.reload()\n}\n\n// reload loads the language files from the provided Loader,\n// the `New` package-level function preloads those files already.\nfunc (i *I18n) reload() error { // May be an exported function, if requested.\n\ti.mu.Lock()\n\tdefer i.mu.Unlock()\n\n\tif i.loader == nil {\n\t\treturn fmt.Errorf(\"nil loader\")\n\t}\n\n\tlocalizer, err := i.loader(i.matcher)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\ti.localizer = localizer\n\treturn nil\n}\n\n// Loaded reports whether `New` or `Load/LoadAssets` called.\nfunc (i *I18n) Loaded() bool {\n\treturn i != nil && i.loader != nil && i.localizer != nil && i.matcher != nil\n}\n\n// Tags returns the registered languages or dynamically resolved by files.\n// Use `Load` or `LoadAssets` first.","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/kataras/iris/blob/7bedaf55a0b64bbb2248a5845a2c60d81a30996a/i18n/i18n.go#L172-L208","documentation":"I18n.reload (invoked by Reset) requires a loader function that knows how to load translation files. If the I18n instance was created without a loader (nil), reloading cannot proceed and this plain error is returned.","triggerScenarios":"Calling i18n.Reset() (or any path that triggers reload) on an I18n instance built without i18n.New(loader...) supplying a loader — e.g. a zero-value I18n or one constructed in tests without wiring a loader.","commonSituations":"Hot-reloading translations on SIGHUP or file change when the app was initialized partially; refactoring away the loader but leaving Reset calls in place; test fixtures constructing &i18n.I18n{} directly.","solutions":["Pass a valid loader to i18n.New (e.g. i18n.Glob, i18n.Dbi or a custom Loader) before calling Reset","Ensure initialization completes before any file-watcher or signal handler triggers reload","Guard reload paths: only call Reset when the loader was configured","If loader is intentionally optional, check i.loader == nil before invoking reload"],"exampleFix":"// before\ni, _ := i18n.New(nil, \"en\")\ni.Reset()\n// after\ni, _ := i18n.New(i18n.Glob(\"./locales/*.json\"), \"en\")\ni.Reset()","handlingStrategy":"type-guard","validationCode":"if i.Loader == nil || reflect.ValueOf(i.Loader).IsNil() {\n    return errors.New(\"i18n: cannot reset without a loader\")\n}","typeGuard":"func (i *I18n) hasLoader() bool { return i.loader != nil }","tryCatchPattern":"if err := i.Reset(); err != nil {\n    if err.Error() == \"nil loader\" {\n        log.Fatal(\"i18n initialized without a loader; cannot reload\")\n    }\n    return err\n}","preventionTips":["Always construct I18n via i18n.New with a real loader (i18n.Glob, i18n.Dbi, custom)","Never call Reset from watchers/signals unless initialization fully succeeded","Keep loader setup and Reset usage in the same bootstrap code","Add a smoke test that calls Reset once at startup"],"tags":["go","i18n","configuration","nil-pointer"],"backgroundTag":"nil-loader-configuration","analyzedSha":"7bedaf55a0b64bbb2248a5845a2c60d81a30996a","analyzedAt":"2026-08-30T20:38:16.250Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}