{"record":{"id":"70caaf57101067f4","repo":"golangci/golangci-lint","slug":"govet-enable-all-and-enable-can-t-be-combined","errorCode":null,"errorMessage":"govet: enable-all and enable can't be combined","messagePattern":"govet: enable-all and enable can't be combined","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/config/linters_settings.go","lineNumber":731,"sourceCode":"}\n\ntype GovetSettings struct {\n\tGo string `mapstructure:\"-\"`\n\n\tEnable     []string `mapstructure:\"enable\"`\n\tDisable    []string `mapstructure:\"disable\"`\n\tEnableAll  bool     `mapstructure:\"enable-all\"`\n\tDisableAll bool     `mapstructure:\"disable-all\"`\n\n\tSettings map[string]map[string]any `mapstructure:\"settings\"`\n}\n\nfunc (cfg *GovetSettings) Validate() error {\n\tif cfg.EnableAll && cfg.DisableAll {\n\t\treturn errors.New(\"govet: enable-all and disable-all can't be combined\")\n\t}\n\tif cfg.EnableAll && len(cfg.Enable) != 0 {\n\t\treturn errors.New(\"govet: enable-all and enable can't be combined\")\n\t}\n\tif cfg.DisableAll && len(cfg.Disable) != 0 {\n\t\treturn errors.New(\"govet: disable-all and disable can't be combined\")\n\t}\n\treturn nil\n}\n\ntype GrouperSettings struct {\n\tConstRequireSingleConst   bool `mapstructure:\"const-require-single-const\"`\n\tConstRequireGrouping      bool `mapstructure:\"const-require-grouping\"`\n\tImportRequireSingleImport bool `mapstructure:\"import-require-single-import\"`\n\tImportRequireGrouping     bool `mapstructure:\"import-require-grouping\"`\n\tTypeRequireSingleType     bool `mapstructure:\"type-require-single-type\"`\n\tTypeRequireGrouping       bool `mapstructure:\"type-require-grouping\"`\n\tVarRequireSingleVar       bool `mapstructure:\"var-require-single-var\"`\n\tVarRequireGrouping        bool `mapstructure:\"var-require-grouping\"`\n}\n","sourceCodeStart":713,"sourceCodeEnd":749,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/config/linters_settings.go#L713-L749","documentation":"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.","triggerScenarios":"Config with `enable-all: true` plus a non-empty `enable:` list under govet settings.","commonSituations":"Switching from selective mode to enable-all but forgetting to delete the old `enable:` list; merged configs from teammates.","solutions":["Remove the `enable:` list entries (they are redundant under enable-all).","Set enable-all: false and rely on an explicit `enable:` list instead.","Move unwanted analyzers to `disable:` instead of trimming `enable:`."],"exampleFix":"# before\nlinters-settings:\n  govet:\n    enable-all: true\n    enable:\n      - shadow\n\n# after\nlinters-settings:\n  govet:\n    enable-all: true","handlingStrategy":"validation","validationCode":"const govet = cfg['linters-settings']?.govet ?? {};\nif (govet['enable-all'] && (govet.enable ?? []).length > 0) {\n  throw new Error('govet: remove `enable` list when enable-all is true');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When switching to enable-all, delete leftover `enable:` entries in the same edit.","Use `golangci-lint config verify` as a pre-commit/CI step.","Document the intended govet mode in the config as a comment."],"tags":["govet","configuration","validation"],"backgroundTag":"mutually-exclusive-config-options","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}