golangci/golangci-lint · error
unknown locale: %q
Error message
unknown locale: %q
What it means
The misspell linter only supports locale configuration for US or UK/GB English dictionaries. createMisspellReplacer explicitly rejects NZ, AU, CA (and any other string) as an unsupported locale, returning this error from the linter constructor New, so golangci-lint fails to initialize misspell.
Source
Thrown at pkg/golinters/misspell/misspell.go:58
}).
WithLoadMode(goanalysis.LoadModeSyntax)
}
func createMisspellReplacer(settings *config.MisspellSettings) (*misspell.Replacer, error) {
replacer := &misspell.Replacer{
Replacements: misspell.DictMain,
}
// Figure out regional variations
switch strings.ToUpper(settings.Locale) {
case "":
// nothing
case "US":
replacer.AddRuleList(misspell.DictAmerican)
case "UK", "GB":
replacer.AddRuleList(misspell.DictBritish)
case "NZ", "AU", "CA":
return nil, fmt.Errorf("unknown locale: %q", settings.Locale)
}
err := appendExtraWords(replacer, settings.ExtraWords)
if err != nil {
return nil, fmt.Errorf("process extra words: %w", err)
}
if len(settings.IgnoreRules) != 0 {
replacer.RemoveRule(settings.IgnoreRules)
}
// It can panic.
replacer.Compile()
return replacer, nil
}
func runMisspellOnFile(pass *analysis.Pass, file *ast.File, replacer *misspell.Replacer, mode string) error {View on GitHub (pinned to ed7a235d2d)
Solutions
- Change locale to "US" for American spelling or "UK"/"GB" for British spelling in .golangci.yml.
- Remove the locale setting entirely to use the default (both dictionaries considered).
- Handle regional differences via misspell's extra-words config instead of an unsupported locale.
- Run `golangci-lint config verify` or docs check to catch unsupported values before running.
Example fix
# before
linters-settings:
misspell:
locale: AU
# after
linters-settings:
misspell:
locale: UK Defensive patterns
Strategy: validation
Validate before calling
func validLocale(l string) bool {
switch l {
case "", "US", "UK", "GB":
return true
}
return false
}
if !validLocale(cfg.Misspell.Locale) { return fmt.Errorf("unsupported locale %q", cfg.Misspell.Locale) } Prevention
- Only set locale to US, UK, or GB in misspell settings.
- Omit the locale key entirely for default behavior.
- Run `golangci-lint config verify` in CI before linting.
- Handle AU/NZ/CA differences via extra-words entries instead of locale.
When it happens
Trigger: Setting linters-settings.misspell.locale to "NZ", "AU", "CA", or any value not in {"US", "UK", "GB", ""} in .golangci.yml.
Common situations: Developers outside US/UK assuming their country code is a valid locale (AU/NZ/CA are listed only to give a clear error); typos like "us-EN" or "en_US"; config copied from tools that do support those locales.
Related errors
- process extra words: %w
- can't get file %s contents: %w
- typo (%q) and correction (%q) fields should not be empty
- the word %q in the 'typo' field should only contain letters
- the word %q in the 'correction' field should only contain le
AI-assisted analysis of golangci/golangci-lint@ed7a235d2d (2026-09-02).
Data as JSON: /api/errors/dea2c8f9cae8561e.
Report an issue: GitHub.