Skip to content

Commit 8b37f14

Browse files
authoredMar 17, 2025··
fix: check version of the configuration (#5564)
1 parent 7bcf51e commit 8b37f14

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed
 

‎pkg/commands/run.go

+4
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ func (c *runCommand) persistentPostRunE(_ *cobra.Command, _ []string) error {
186186
}
187187

188188
func (c *runCommand) preRunE(_ *cobra.Command, args []string) error {
189+
if c.cfg.GetConfigDir() != "" && c.cfg.Version != "" {
190+
return errors.New("you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2")
191+
}
192+
189193
dbManager, err := lintersdb.NewManager(c.log.Child(logutils.DebugKeyLintersDB), c.cfg,
190194
lintersdb.NewLinterBuilder(), lintersdb.NewPluginModuleBuilder(c.log), lintersdb.NewPluginGoBuilder(c.log))
191195
if err != nil {

‎pkg/config/config.go

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ type Config struct {
2020
cfgDir string // Path to the directory containing golangci-lint config file.
2121
basePath string // Path the root directory related to [Run.RelativePathMode].
2222

23+
Version string `mapstructure:"version"` // From v2, to be able to detect v2 config file.
24+
2325
Run Run `mapstructure:"run"`
2426

2527
Output Output `mapstructure:"output"`

0 commit comments

Comments
 (0)
Please sign in to comment.