diff --git a/pkg/lint/linter/config.go b/pkg/lint/linter/config.go index 57c51fa75e4c..f157ad3d4ce4 100644 --- a/pkg/lint/linter/config.go +++ b/pkg/lint/linter/config.go @@ -163,6 +163,16 @@ func (lc *Config) WithNoopFallback(cfg *config.Config, cond func(cfg *config.Con return lc } +func IsGoGreaterThanOrEqualGo122() func(cfg *config.Config) error { + return func(cfg *config.Config) error { + if cfg == nil || !config.IsGoGreaterThanOrEqual(cfg.Run.Go, "1.22") { + return nil + } + + return fmt.Errorf("this linter is disabled because the Go version (%s) of your project is greater than or equal Go 1.22", cfg.Run.Go) + } +} + func IsGoLowerThanGo122() func(cfg *config.Config) error { return func(cfg *config.Config) error { if cfg == nil || config.IsGoGreaterThanOrEqual(cfg.Run.Go, "1.22") { diff --git a/pkg/lint/lintersdb/builder_linter.go b/pkg/lint/lintersdb/builder_linter.go index 3a46cbf88e5e..2139f5db2278 100644 --- a/pkg/lint/lintersdb/builder_linter.go +++ b/pkg/lint/lintersdb/builder_linter.go @@ -278,7 +278,8 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithSince("v1.28.0"). WithPresets(linter.PresetBugs). WithLoadForGoAnalysis(). - WithURL("https://github.com/kyoh86/exportloopref"), + WithURL("https://github.com/kyoh86/exportloopref"). + WithNoopFallback(cfg, linter.IsGoGreaterThanOrEqualGo122()), linter.NewConfig(forbidigo.New(&cfg.LintersSettings.Forbidigo)). WithSince("v1.34.0").