golangci/golangci-lint · error
failed to create meta-formatter: %w
Error message
failed to create meta-formatter: %w
What it means
NewRunner builds a MetaFormatter (goformatters.NewMetaFormatter) from the enabled formatter list and formatter settings. If the formatter set or its settings are invalid, construction fails and the error is wrapped as "failed to create meta-formatter", so the runner never starts.
Source
Thrown at pkg/lint/runner.go:78
}
switch len(enabledLinters) {
case 0:
return nil, errors.New("no linters enabled")
case 1:
if _, ok := enabledLinters["typecheck"]; ok {
return nil, errors.New("no linters enabled")
}
}
formattersCfg := &config.Formatters{
Enable: enabledFormatters,
Settings: cfg.Linters.Settings.FormatterSettings,
}
metaFormatter, err := goformatters.NewMetaFormatter(log, formattersCfg, &cfg.Run)
if err != nil {
return nil, fmt.Errorf("failed to create meta-formatter: %w", err)
}
return &Runner{
Processors: []processors.Processor{
// Must be the first processor.
processors.NewPathAbsoluter(log),
processors.NewCgo(goenv),
// Must be after Cgo.
processors.NewFilenameUnadjuster(lintCtx.Packages, log.Child(logutils.DebugKeyFilenameUnadjuster)),
// Must be after FilenameUnadjuster.
processors.NewInvalidIssue(log.Child(logutils.DebugKeyInvalidIssue)),
// Must be after PathAbsoluter, Cgo, FilenameUnadjuster InvalidIssue.
pathRelativity,
View on GitHub (pinned to ed7a235d2d)
Solutions
- Read the wrapped %w cause — it identifies which formatter or setting failed
- Validate settings under `linters-settings.formatters` against the docs for your golangci-lint version
- Run `golangci-lint config verify` to catch schema issues in formatter settings
- Remove/disable the failing formatter and re-add settings incrementally
Example fix
// before (.golangci.yml)
linters-settings:
formatters:
gci:
custom-sections: bogus
// after
linters-settings:
formatters:
gci:
sections:
- standard
- default Defensive patterns
Strategy: validation
Validate before calling
// Validate formatter settings before running: // golangci-lint config verify // golangci-lint fmt --diff . # run formatters standalone to see init/usage errors
Try / catch
metaFormatter, err := goformatters.NewMetaFormatter(log, formattersCfg, &cfg.Run)
if err != nil {
return fmt.Errorf("failed to create meta-formatter: %w", err)
} Prevention
- Keep formatter settings keys aligned with your golangci-lint version's docs
- Enable only one canonical formatter per concern (gofmt OR gofumpt, not both)
- Run `golangci-lint config verify` as a pre-commit/CI step
- Change formatter settings one key at a time and re-run to isolate breakage
When it happens
Trigger: Enabled formatters (auto-detected from enabledLinters via goformatters.IsFormatter) that cannot be instantiated, or malformed `linters-settings.formatters` / formatter-specific settings (e.g. invalid gofmt options, bad revision for gci) passed via formattersCfg.
Common situations: Enabling formatters like gofmt/goimports/gci/gofumpt with incompatible or invalid settings blocks; new settings keys introduced in a golangci-lint version not recognized by the installed binary; typos in formatter settings.
Related errors
- can't get enabled formatters: %w
- error while running %s: %w
- can't combine option --config and --no-config
- failed to create meta-formatter: %w
- build walk options: %w
AI-assisted analysis of golangci/golangci-lint@ed7a235d2d (2026-09-02).
Data as JSON: /api/errors/8899794e59d3fec0.
Report an issue: GitHub.