golangci/golangci-lint · error

%s is not a formatter

Error message

%s is not a formatter

What it means

Formatters.Validate checks each name in formatters.enable against the registry of known formatter names (e.g. gofmt, gofumpt, goimports). Any unknown name produces this error. It catches misspelled or non-formatter tools configured in the formatters section.

Source

Thrown at pkg/config/formatters.go:17

package config

import (
	"fmt"
	"slices"
)

type Formatters struct {
	Enable     []string            `mapstructure:"enable"`
	Settings   FormatterSettings   `mapstructure:"settings"`
	Exclusions FormatterExclusions `mapstructure:"exclusions"`
}

func (f *Formatters) Validate() error {
	for _, n := range f.Enable {
		if !slices.Contains(getAllFormatterNames(), n) {
			return fmt.Errorf("%s is not a formatter", n)
		}
	}

	return nil
}

type FormatterExclusions struct {
	Generated  string   `mapstructure:"generated"`
	Paths      []string `mapstructure:"paths"`
	WarnUnused bool     `mapstructure:"warn-unused"`
}

View on GitHub (pinned to ed7a235d2d)

Solutions

  1. Correct the name in formatters.enable to a valid formatter (gofmt, gofmt, goimports, gofumpt, golines, etc.)
  2. Run 'golangci-lint formatters' to list valid formatter names
  3. Move the entry to linters.enable if it is actually a linter, not a formatter

Example fix

# before
formatters:
  enable:
    - gofmpt
# after
formatters:
  enable:
    - gofumpt
Defensive patterns

Strategy: validation

Validate before calling

var knownFormatters = []string{"gofmt","goimports","gofumpt","golines","swaggo","gci"}
for _, n := range cfg.Formatters.Enable {
	if !slices.Contains(knownFormatters, n) {
		return fmt.Errorf("%s is not a formatter", n)
	}
}

Try / catch

if err := formatters.Validate(); err != nil { log.Fatalf("formatter config: %v", err) }

Prevention

When it happens

Trigger: Config file containing formatters.enable: [xyz] where xyz is not a registered formatter name (typo, removed formatter, or a linter placed in the formatters section).

Common situations: Typing 'gofmpt' instead of 'gofumpt'; migrating from v1 where some tools were linters; using a custom/plugin linter name under formatters.

Related errors


AI-assisted analysis of golangci/golangci-lint@ed7a235d2d (2026-09-02). Data as JSON: /api/errors/fb1b3856b7598e2b. Report an issue: GitHub.