golangci/golangci-lint · error
govet: disable-all and disable can't be combined
Error message
govet: disable-all and disable can't be combined
What it means
Validation guard in GovetSettings.Validate: the user's golangci-lint config set both disable-all and enable under linters-settings.govet, which is contradictory (disable-all turns every govet analyzer off, so an enable list has nothing to enable). The check compares the DisableAll flag against a non-empty Enable slice and fails fast before running.
Source
Thrown at pkg/config/linters_settings.go:734
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"`
}
type IfaceSettings struct {
Enable []string `mapstructure:"enable"`
Settings map[string]map[string]any `mapstructure:"settings"`View on GitHub (pinned to ed7a235d2d)
Solutions
- Remove the `disable:` list entries (redundant under disable-all).
- Set disable-all: false and use an explicit `disable:` list with default-enabled analyzers.
- List the analyzers you actually want in `enable:` instead.
Example fix
# before
linters-settings:
govet:
disable-all: true
disable:
- shadow
# after
linters-settings:
govet:
disable-all: true
enable:
- bodyclose Defensive patterns
Strategy: validation
Validate before calling
const govet = cfg['linters-settings']?.govet ?? {};
if (govet['disable-all'] && (govet.disable ?? []).length > 0) {
throw new Error('govet: remove `disable` list when disable-all is true');
} Prevention
- When switching to disable-all, move former `disable` entries to `enable` if needed.
- Run `golangci-lint config verify` before committing config changes.
- Keep govet settings minimal and reviewed.
When it happens
Trigger: Config with `disable-all: true` plus a non-empty `disable:` list under govet settings.
Common situations: Copy-pasted settings where someone added disable-all: true but kept an old `disable:` list; config merge artifacts.
Related errors
- govet: enable-all and disable-all can't be combined
- govet: enable-all and enable can't be combined
- path and path-except should not be set at the same time
- the configuration contains invalid elements
- root field 'version' is required
AI-assisted analysis of golangci/golangci-lint@ed7a235d2d (2026-09-02).
Data as JSON: /api/errors/6effd9f826bbd272.
Report an issue: GitHub.