golangci/golangci-lint · error

govet: enable-all and enable can't be combined

Error message

govet: enable-all and enable can't be combined

What it means

GovetSettings.Validate rejects govet configs where enable-all is true while the `enable` list is non-empty — explicitly enabling analyzers is meaningless (and likely a mistake) when all are already enabled.

Source

Thrown at pkg/config/linters_settings.go:731

}

type GovetSettings struct {
	Go string `mapstructure:"-"`

	Enable     []string `mapstructure:"enable"`
	Disable    []string `mapstructure:"disable"`
	EnableAll  bool     `mapstructure:"enable-all"`
	DisableAll bool     `mapstructure:"disable-all"`

	Settings map[string]map[string]any `mapstructure:"settings"`
}

func (cfg *GovetSettings) Validate() error {
	if cfg.EnableAll && cfg.DisableAll {
		return errors.New("govet: enable-all and disable-all can't be combined")
	}
	if cfg.EnableAll && len(cfg.Enable) != 0 {
		return errors.New("govet: enable-all and enable can't be combined")
	}
	if cfg.DisableAll && len(cfg.Disable) != 0 {
		return errors.New("govet: disable-all and disable can't be combined")
	}
	return nil
}

type GrouperSettings struct {
	ConstRequireSingleConst   bool `mapstructure:"const-require-single-const"`
	ConstRequireGrouping      bool `mapstructure:"const-require-grouping"`
	ImportRequireSingleImport bool `mapstructure:"import-require-single-import"`
	ImportRequireGrouping     bool `mapstructure:"import-require-grouping"`
	TypeRequireSingleType     bool `mapstructure:"type-require-single-type"`
	TypeRequireGrouping       bool `mapstructure:"type-require-grouping"`
	VarRequireSingleVar       bool `mapstructure:"var-require-single-var"`
	VarRequireGrouping        bool `mapstructure:"var-require-grouping"`
}

View on GitHub (pinned to ed7a235d2d)

Solutions

  1. Remove the `enable:` list entries (they are redundant under enable-all).
  2. Set enable-all: false and rely on an explicit `enable:` list instead.
  3. Move unwanted analyzers to `disable:` instead of trimming `enable:`.

Example fix

# before
linters-settings:
  govet:
    enable-all: true
    enable:
      - shadow

# after
linters-settings:
  govet:
    enable-all: true
Defensive patterns

Strategy: validation

Validate before calling

const govet = cfg['linters-settings']?.govet ?? {};
if (govet['enable-all'] && (govet.enable ?? []).length > 0) {
  throw new Error('govet: remove `enable` list when enable-all is true');
}

Prevention

When it happens

Trigger: Config with `enable-all: true` plus a non-empty `enable:` list under govet settings.

Common situations: Switching from selective mode to enable-all but forgetting to delete the old `enable:` list; merged configs from teammates.

Related errors


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