diff --git a/pkg/golinters/goanalysis/runner_loadingpackage.go b/pkg/golinters/goanalysis/runner_loadingpackage.go index 0a9653b8d20c..a5b5cccfeef7 100644 --- a/pkg/golinters/goanalysis/runner_loadingpackage.go +++ b/pkg/golinters/goanalysis/runner_loadingpackage.go @@ -121,7 +121,15 @@ func (lp *loadingPackage) loadFromSource(loadMode LoadMode) error { pkg.IllTyped = true - pkg.TypesInfo = newTypesInfo() + pkg.TypesInfo = &types.Info{ + Types: make(map[ast.Expr]types.TypeAndValue), + Instances: make(map[*ast.Ident]types.Instance), + Defs: make(map[*ast.Ident]types.Object), + Uses: make(map[*ast.Ident]types.Object), + Implicits: make(map[ast.Node]types.Object), + Scopes: make(map[ast.Node]*types.Scope), + Selections: make(map[*ast.SelectorExpr]*types.Selection), + } importer := func(path string) (*types.Package, error) { if path == unsafePkgName { diff --git a/pkg/golinters/goanalysis/runner_loadingpackage_ti.go b/pkg/golinters/goanalysis/runner_loadingpackage_ti.go deleted file mode 100644 index 798add627074..000000000000 --- a/pkg/golinters/goanalysis/runner_loadingpackage_ti.go +++ /dev/null @@ -1,21 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -package goanalysis - -import ( - "go/ast" - "go/types" -) - -func newTypesInfo() *types.Info { - return &types.Info{ - Types: make(map[ast.Expr]types.TypeAndValue), - Instances: make(map[*ast.Ident]types.Instance), - Defs: make(map[*ast.Ident]types.Object), - Uses: make(map[*ast.Ident]types.Object), - Implicits: make(map[ast.Node]types.Object), - Scopes: make(map[ast.Node]*types.Scope), - Selections: make(map[*ast.SelectorExpr]*types.Selection), - } -} diff --git a/pkg/golinters/goanalysis/runner_loadingpackage_ti_go117.go b/pkg/golinters/goanalysis/runner_loadingpackage_ti_go117.go deleted file mode 100644 index 096ac97c5f07..000000000000 --- a/pkg/golinters/goanalysis/runner_loadingpackage_ti_go117.go +++ /dev/null @@ -1,20 +0,0 @@ -//go:build go1.17 && !go1.18 -// +build go1.17,!go1.18 - -package goanalysis - -import ( - "go/ast" - "go/types" -) - -func newTypesInfo() *types.Info { - return &types.Info{ - Types: make(map[ast.Expr]types.TypeAndValue), - Defs: make(map[*ast.Ident]types.Object), - Uses: make(map[*ast.Ident]types.Object), - Implicits: make(map[ast.Node]types.Object), - Scopes: make(map[ast.Node]*types.Scope), - Selections: make(map[*ast.SelectorExpr]*types.Selection), - } -} diff --git a/pkg/lint/linter/linter.go b/pkg/lint/linter/linter.go index 01e2196911e0..7d3b2260a519 100644 --- a/pkg/lint/linter/linter.go +++ b/pkg/lint/linter/linter.go @@ -21,8 +21,8 @@ type Noop struct { } func (n Noop) Run(_ context.Context, lintCtx *Context) ([]result.Issue, error) { - lintCtx.Log.Warnf("%s is disabled because of go1.18."+ - " You can track the evolution of the go1.18 support by following the https://github.com/golangci/golangci-lint/issues/2649.", n.name) + lintCtx.Log.Warnf("%s is disabled because of generics."+ + " You can track the evolution of the generics support by following the https://github.com/golangci/golangci-lint/issues/2649.", n.name) return nil, nil } diff --git a/test/linters_test.go b/test/linters_test.go index a5d2a3c0ab7b..9e5d641f5edd 100644 --- a/test/linters_test.go +++ b/test/linters_test.go @@ -312,15 +312,10 @@ func extractRunContextFromComments(t *testing.T, sourcePath string) *runContext require.Failf(t, "invalid prefix of comment line %s", line) } - // TODO(ldez) replace that by strings.Cut when we will drop go1.17 - var before string - var after string - if i := strings.Index(line, " "); i >= 0 { - before = line[:i] - after = strings.TrimSpace(line[i+len(" "):]) - } else { - require.Failf(t, "invalid prefix of comment line %s", line) - } + before, after, found := strings.Cut(line, " ") + require.Truef(t, found, "invalid prefix of comment line %s", line) + + after = strings.TrimSpace(after) switch before { case "//golangcitest:args":