golangci/golangci-lint · error

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

Error message

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

What it means

GovetSettings.Validate rejects linters-settings.govet configs where both enable-all and disable-all are true. Enabling and disabling all analyzers simultaneously is contradictory, so the config is invalid.

Source

Thrown at pkg/config/linters_settings.go:728

	AllowTimeLocal  bool     `mapstructure:"allow-time-local"`
	EscapeHatches   []string `mapstructure:"escape-hatches"`
	WatchForScripts []string `mapstructure:"watch-for-scripts"`
}

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"`

View on GitHub (pinned to ed7a235d2d)

Solutions

  1. Keep only one of enable-all / disable-all set to true under govet.
  2. If the goal is enable-all with a few off, use enable-all: true plus `disable: [...]`.
  3. If the goal is disable-all with a few on, use disable-all: true plus `enable: [...]`.

Example fix

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

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

Strategy: validation

Validate before calling

const govet = cfg['linters-settings']?.govet ?? {};
if (govet['enable-all'] && govet['disable-all']) {
  throw new Error('govet: pick either enable-all or disable-all, not both');
}

Prevention

When it happens

Trigger: Setting both `enable-all: true` and `disable-all: true` under govet settings in .golangci.yml, then running any command that validates linters settings.

Common situations: Copy-pasting config examples that each set a different *-all flag; YAML merge tools combining two govet blocks.

Related errors


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