diff --git a/pkg/commands/run.go b/pkg/commands/run.go index 3aa467daef3f..57f3cdd9936f 100644 --- a/pkg/commands/run.go +++ b/pkg/commands/run.go @@ -186,6 +186,10 @@ func (c *runCommand) persistentPostRunE(_ *cobra.Command, _ []string) error { } func (c *runCommand) preRunE(_ *cobra.Command, args []string) error { + if c.cfg.GetConfigDir() != "" && c.cfg.Version != "" { + return errors.New("you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2") + } + dbManager, err := lintersdb.NewManager(c.log.Child(logutils.DebugKeyLintersDB), c.cfg, lintersdb.NewLinterBuilder(), lintersdb.NewPluginModuleBuilder(c.log), lintersdb.NewPluginGoBuilder(c.log)) if err != nil { diff --git a/pkg/config/config.go b/pkg/config/config.go index 4ddd896170d9..ee7a62b7e229 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -20,6 +20,8 @@ type Config struct { cfgDir string // Path to the directory containing golangci-lint config file. basePath string // Path the root directory related to [Run.RelativePathMode]. + Version string `mapstructure:"version"` // From v2, to be able to detect v2 config file. + Run Run `mapstructure:"run"` Output Output `mapstructure:"output"`