diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index b8445c5591eb..e49e9f879c9a 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -35,6 +35,7 @@ linters: - exhaustive - exhaustruct - exportloopref + - exptostd - fatcontext - forbidigo - forcetypeassert @@ -153,6 +154,7 @@ linters: - exhaustive - exhaustruct - exportloopref + - exptostd - fatcontext - forbidigo - forcetypeassert diff --git a/go.mod b/go.mod index 89100b2ade66..7bbf802cc9f1 100644 --- a/go.mod +++ b/go.mod @@ -65,6 +65,7 @@ require ( github.com/kunwardeep/paralleltest v1.0.10 github.com/kyoh86/exportloopref v0.1.11 github.com/lasiar/canonicalheader v1.1.2 + github.com/ldez/exptostd v0.3.0 github.com/ldez/gomoddirectives v0.6.0 github.com/ldez/grignotin v0.7.0 github.com/ldez/tagliatelle v0.7.1 diff --git a/go.sum b/go.sum index fe4fe0f80910..a3d4b0fb7ee1 100644 --- a/go.sum +++ b/go.sum @@ -353,6 +353,8 @@ github.com/kyoh86/exportloopref v0.1.11 h1:1Z0bcmTypkL3Q4k+IDHMWTcnCliEZcaPiIe0/ github.com/kyoh86/exportloopref v0.1.11/go.mod h1:qkV4UF1zGl6EkF1ox8L5t9SwyeBAZ3qLMd6up458uqA= github.com/lasiar/canonicalheader v1.1.2 h1:vZ5uqwvDbyJCnMhmFYimgMZnJMjwljN5VGY0VKbMXb4= github.com/lasiar/canonicalheader v1.1.2/go.mod h1:qJCeLFS0G/QlLQ506T+Fk/fWMa2VmBUiEI2cuMK4djI= +github.com/ldez/exptostd v0.3.0 h1:iKdMtUedzov89jDvuwmo0qpo+ARpZJg9hMp3428WwNg= +github.com/ldez/exptostd v0.3.0/go.mod h1:iZBRYaUmcW5jwCR3KROEZ1KivQQp6PHXbDPk9hqJKCQ= github.com/ldez/gomoddirectives v0.6.0 h1:Jyf1ZdTeiIB4dd+2n4qw+g4aI9IJ6JyfOZ8BityWvnA= github.com/ldez/gomoddirectives v0.6.0/go.mod h1:TuwOGYoPAoENDWQpe8DMqEm5nIfjrxZXmxX/CExWyZ4= github.com/ldez/grignotin v0.7.0 h1:vh0dI32WhHaq6LLPZ38g7WxXuZ1+RzyrJ7iPG9JMa8c= diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index 6553bc369cea..4d94d0674f65 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -350,6 +350,7 @@ "exhaustive", "exhaustruct", "exportloopref", + "exptostd", "fatcontext", "forbidigo", "forcetypeassert", diff --git a/pkg/golinters/exptostd/exptostd.go b/pkg/golinters/exptostd/exptostd.go new file mode 100644 index 000000000000..2de8ea98c2b8 --- /dev/null +++ b/pkg/golinters/exptostd/exptostd.go @@ -0,0 +1,19 @@ +package exptostd + +import ( + "github.com/ldez/exptostd" + "golang.org/x/tools/go/analysis" + + "github.com/golangci/golangci-lint/pkg/goanalysis" +) + +func New() *goanalysis.Linter { + a := exptostd.NewAnalyzer() + + return goanalysis.NewLinter( + a.Name, + a.Doc, + []*analysis.Analyzer{a}, + nil, + ).WithLoadMode(goanalysis.LoadModeTypesInfo) +} diff --git a/pkg/golinters/exptostd/exptostd_integration_test.go b/pkg/golinters/exptostd/exptostd_integration_test.go new file mode 100644 index 000000000000..8c8e325e2aa3 --- /dev/null +++ b/pkg/golinters/exptostd/exptostd_integration_test.go @@ -0,0 +1,19 @@ +package exptostd + +import ( + "testing" + + "github.com/golangci/golangci-lint/test/testshared/integration" +) + +func TestFromTestdata(t *testing.T) { + integration.RunTestdata(t) +} + +func TestFix(t *testing.T) { + integration.RunFix(t) +} + +func TestFixPathPrefix(t *testing.T) { + integration.RunFixPathPrefix(t) +} diff --git a/pkg/golinters/exptostd/testdata/exptostd.go b/pkg/golinters/exptostd/testdata/exptostd.go new file mode 100644 index 000000000000..527da55211c0 --- /dev/null +++ b/pkg/golinters/exptostd/testdata/exptostd.go @@ -0,0 +1,85 @@ +//golangcitest:args -Eexptostd +package testdata + +import ( + "fmt" + + "golang.org/x/exp/maps" // want `Import statement 'golang.org/x/exp/maps' can be replaced by 'maps'` + "golang.org/x/exp/slices" // want `Import statement 'golang.org/x/exp/slices' can be replaced by 'slices'` +) + +func _(m, a map[string]string) { + maps.Clone(m) // want `golang.org/x/exp/maps.Clone\(\) can be replaced by maps.Clone\(\)` + + maps.Equal(m, a) // want `golang.org/x/exp/maps.Equal\(\) can be replaced by maps.Equal\(\)` + + maps.EqualFunc(m, a, func(i, j string) bool { // want `golang.org/x/exp/maps.EqualFunc\(\) can be replaced by maps.EqualFunc\(\)` + return true + }) + + maps.Copy(m, a) // want `golang.org/x/exp/maps.Copy\(\) can be replaced by maps.Copy\(\)` + + maps.DeleteFunc(m, func(_, _ string) bool { // want `golang.org/x/exp/maps.DeleteFunc\(\) can be replaced by maps.DeleteFunc\(\)` + return true + }) + + maps.Clear(m) // want `golang.org/x/exp/maps.Clear\(\) can be replaced by clear\(\)` + + fmt.Println("Hello") +} + +func _(a, b []string) { + slices.Equal(a, b) + slices.EqualFunc(a, b, func(_ string, _ string) bool { + return true + }) + slices.Compare(a, b) + slices.CompareFunc(a, b, func(_ string, _ string) int { + return 0 + }) + slices.Index(a, "a") + slices.IndexFunc(a, func(_ string) bool { + return true + }) + slices.Contains(a, "a") + slices.ContainsFunc(a, func(_ string) bool { + return true + }) + slices.Insert(a, 0, "a", "b") + slices.Delete(a, 0, 1) + slices.DeleteFunc(a, func(_ string) bool { + return true + }) + slices.Replace(a, 0, 1, "a") + slices.Clone(a) + slices.Compact(a) + slices.CompactFunc(a, func(_ string, _ string) bool { + return true + }) + slices.Grow(a, 2) + slices.Clip(a) + slices.Reverse(a) + slices.Sort(a) + slices.SortFunc(a, func(_, _ string) int { + return 0 + }) + slices.SortStableFunc(a, func(_, _ string) int { + return 0 + }) + slices.IsSorted(a) + slices.IsSortedFunc(a, func(_, _ string) int { + return 0 + }) + slices.Min(a) + slices.MinFunc(a, func(_, _ string) int { + return 0 + }) + slices.Max(a) + slices.MaxFunc(a, func(_, _ string) int { + return 0 + }) + slices.BinarySearch(a, "a") + slices.BinarySearchFunc(a, b, func(_ string, _ []string) int { + return 0 + }) +} diff --git a/pkg/golinters/exptostd/testdata/exptostd_cgo.go b/pkg/golinters/exptostd/testdata/exptostd_cgo.go new file mode 100644 index 000000000000..f036865f2ba4 --- /dev/null +++ b/pkg/golinters/exptostd/testdata/exptostd_cgo.go @@ -0,0 +1,102 @@ +//golangcitest:args -Eexptostd +package testdata + +/* + #include + #include + + void myprint(char* s) { + printf("%d\n", s); + } +*/ +import "C" + +import ( + "fmt" + "unsafe" + + "golang.org/x/exp/maps" // want `Import statement 'golang.org/x/exp/maps' can be replaced by 'maps'` + "golang.org/x/exp/slices" // want `Import statement 'golang.org/x/exp/slices' can be replaced by 'slices'` +) + +func _() { + cs := C.CString("Hello from stdio\n") + C.myprint(cs) + C.free(unsafe.Pointer(cs)) +} + +func _(m, a map[string]string) { + maps.Clone(m) // want `golang.org/x/exp/maps.Clone\(\) can be replaced by maps.Clone\(\)` + + maps.Equal(m, a) // want `golang.org/x/exp/maps.Equal\(\) can be replaced by maps.Equal\(\)` + + maps.EqualFunc(m, a, func(i, j string) bool { // want `golang.org/x/exp/maps.EqualFunc\(\) can be replaced by maps.EqualFunc\(\)` + return true + }) + + maps.Copy(m, a) // want `golang.org/x/exp/maps.Copy\(\) can be replaced by maps.Copy\(\)` + + maps.DeleteFunc(m, func(_, _ string) bool { // want `golang.org/x/exp/maps.DeleteFunc\(\) can be replaced by maps.DeleteFunc\(\)` + return true + }) + + maps.Clear(m) // want `golang.org/x/exp/maps.Clear\(\) can be replaced by clear\(\)` + + fmt.Println("Hello") +} + +func _(a, b []string) { + slices.Equal(a, b) + slices.EqualFunc(a, b, func(_ string, _ string) bool { + return true + }) + slices.Compare(a, b) + slices.CompareFunc(a, b, func(_ string, _ string) int { + return 0 + }) + slices.Index(a, "a") + slices.IndexFunc(a, func(_ string) bool { + return true + }) + slices.Contains(a, "a") + slices.ContainsFunc(a, func(_ string) bool { + return true + }) + slices.Insert(a, 0, "a", "b") + slices.Delete(a, 0, 1) + slices.DeleteFunc(a, func(_ string) bool { + return true + }) + slices.Replace(a, 0, 1, "a") + slices.Clone(a) + slices.Compact(a) + slices.CompactFunc(a, func(_ string, _ string) bool { + return true + }) + slices.Grow(a, 2) + slices.Clip(a) + slices.Reverse(a) + slices.Sort(a) + slices.SortFunc(a, func(_, _ string) int { + return 0 + }) + slices.SortStableFunc(a, func(_, _ string) int { + return 0 + }) + slices.IsSorted(a) + slices.IsSortedFunc(a, func(_, _ string) int { + return 0 + }) + slices.Min(a) + slices.MinFunc(a, func(_, _ string) int { + return 0 + }) + slices.Max(a) + slices.MaxFunc(a, func(_, _ string) int { + return 0 + }) + slices.BinarySearch(a, "a") + slices.BinarySearchFunc(a, b, func(_ string, _ []string) int { + return 0 + }) +} diff --git a/pkg/golinters/exptostd/testdata/exptostd_go123.go b/pkg/golinters/exptostd/testdata/exptostd_go123.go new file mode 100644 index 000000000000..b610b2d727f5 --- /dev/null +++ b/pkg/golinters/exptostd/testdata/exptostd_go123.go @@ -0,0 +1,91 @@ +//go:build go1.23 + +//golangcitest:args -Eexptostd +package testdata + +import ( + "fmt" + + "golang.org/x/exp/maps" // want `Import statement 'golang.org/x/exp/maps' can be replaced by 'maps'` + "golang.org/x/exp/slices" // want `Import statement 'golang.org/x/exp/slices' can be replaced by 'slices'` +) + +func _(m, a map[string]string) { + maps.Clone(m) // want `golang.org/x/exp/maps.Clone\(\) can be replaced by maps.Clone\(\)` + + maps.Keys(m) // want `golang.org/x/exp/maps.Keys\(\) can be replaced by slices.Collect\(maps.Keys\(\)\)` + + maps.Values(m) // want `golang.org/x/exp/maps.Values\(\) can be replaced by slices.Collect\(maps.Values\(\)\)` + + maps.Equal(m, a) // want `golang.org/x/exp/maps.Equal\(\) can be replaced by maps.Equal\(\)` + + maps.EqualFunc(m, a, func(i, j string) bool { // want `golang.org/x/exp/maps.EqualFunc\(\) can be replaced by maps.EqualFunc\(\)` + return true + }) + + maps.Copy(m, a) // want `golang.org/x/exp/maps.Copy\(\) can be replaced by maps.Copy\(\)` + + maps.DeleteFunc(m, func(_, _ string) bool { // want `golang.org/x/exp/maps.DeleteFunc\(\) can be replaced by maps.DeleteFunc\(\)` + return true + }) + + maps.Clear(m) // want `golang.org/x/exp/maps.Clear\(\) can be replaced by clear\(\)` + + fmt.Println("Hello") +} + +func _(a, b []string) { + slices.Equal(a, b) + slices.EqualFunc(a, b, func(_ string, _ string) bool { + return true + }) + slices.Compare(a, b) + slices.CompareFunc(a, b, func(_ string, _ string) int { + return 0 + }) + slices.Index(a, "a") + slices.IndexFunc(a, func(_ string) bool { + return true + }) + slices.Contains(a, "a") + slices.ContainsFunc(a, func(_ string) bool { + return true + }) + slices.Insert(a, 0, "a", "b") + slices.Delete(a, 0, 1) + slices.DeleteFunc(a, func(_ string) bool { + return true + }) + slices.Replace(a, 0, 1, "a") + slices.Clone(a) + slices.Compact(a) + slices.CompactFunc(a, func(_ string, _ string) bool { + return true + }) + slices.Grow(a, 2) + slices.Clip(a) + slices.Reverse(a) + slices.Sort(a) + slices.SortFunc(a, func(_, _ string) int { + return 0 + }) + slices.SortStableFunc(a, func(_, _ string) int { + return 0 + }) + slices.IsSorted(a) + slices.IsSortedFunc(a, func(_, _ string) int { + return 0 + }) + slices.Min(a) + slices.MinFunc(a, func(_, _ string) int { + return 0 + }) + slices.Max(a) + slices.MaxFunc(a, func(_, _ string) int { + return 0 + }) + slices.BinarySearch(a, "a") + slices.BinarySearchFunc(a, b, func(_ string, _ []string) int { + return 0 + }) +} diff --git a/pkg/golinters/exptostd/testdata/exptostd_go123_cgo.go b/pkg/golinters/exptostd/testdata/exptostd_go123_cgo.go new file mode 100644 index 000000000000..892624fd38b0 --- /dev/null +++ b/pkg/golinters/exptostd/testdata/exptostd_go123_cgo.go @@ -0,0 +1,108 @@ +//go:build go1.23 + +//golangcitest:args -Eexptostd +package testdata + +/* + #include + #include + + void myprint(char* s) { + printf("%d\n", s); + } +*/ +import "C" + +import ( + "fmt" + "unsafe" + + "golang.org/x/exp/maps" // want `Import statement 'golang.org/x/exp/maps' can be replaced by 'maps'` + "golang.org/x/exp/slices" // want `Import statement 'golang.org/x/exp/slices' can be replaced by 'slices'` +) + +func _() { + cs := C.CString("Hello from stdio\n") + C.myprint(cs) + C.free(unsafe.Pointer(cs)) +} + +func _(m, a map[string]string) { + maps.Clone(m) // want `golang.org/x/exp/maps.Clone\(\) can be replaced by maps.Clone\(\)` + + maps.Keys(m) // want `golang.org/x/exp/maps.Keys\(\) can be replaced by slices.Collect\(maps.Keys\(\)\)` + + maps.Values(m) // want `golang.org/x/exp/maps.Values\(\) can be replaced by slices.Collect\(maps.Values\(\)\)` + + maps.Equal(m, a) // want `golang.org/x/exp/maps.Equal\(\) can be replaced by maps.Equal\(\)` + + maps.EqualFunc(m, a, func(i, j string) bool { // want `golang.org/x/exp/maps.EqualFunc\(\) can be replaced by maps.EqualFunc\(\)` + return true + }) + + maps.Copy(m, a) // want `golang.org/x/exp/maps.Copy\(\) can be replaced by maps.Copy\(\)` + + maps.DeleteFunc(m, func(_, _ string) bool { // want `golang.org/x/exp/maps.DeleteFunc\(\) can be replaced by maps.DeleteFunc\(\)` + return true + }) + + maps.Clear(m) // want `golang.org/x/exp/maps.Clear\(\) can be replaced by clear\(\)` + + fmt.Println("Hello") +} + +func _(a, b []string) { + slices.Equal(a, b) + slices.EqualFunc(a, b, func(_ string, _ string) bool { + return true + }) + slices.Compare(a, b) + slices.CompareFunc(a, b, func(_ string, _ string) int { + return 0 + }) + slices.Index(a, "a") + slices.IndexFunc(a, func(_ string) bool { + return true + }) + slices.Contains(a, "a") + slices.ContainsFunc(a, func(_ string) bool { + return true + }) + slices.Insert(a, 0, "a", "b") + slices.Delete(a, 0, 1) + slices.DeleteFunc(a, func(_ string) bool { + return true + }) + slices.Replace(a, 0, 1, "a") + slices.Clone(a) + slices.Compact(a) + slices.CompactFunc(a, func(_ string, _ string) bool { + return true + }) + slices.Grow(a, 2) + slices.Clip(a) + slices.Reverse(a) + slices.Sort(a) + slices.SortFunc(a, func(_, _ string) int { + return 0 + }) + slices.SortStableFunc(a, func(_, _ string) int { + return 0 + }) + slices.IsSorted(a) + slices.IsSortedFunc(a, func(_, _ string) int { + return 0 + }) + slices.Min(a) + slices.MinFunc(a, func(_, _ string) int { + return 0 + }) + slices.Max(a) + slices.MaxFunc(a, func(_, _ string) int { + return 0 + }) + slices.BinarySearch(a, "a") + slices.BinarySearchFunc(a, b, func(_ string, _ []string) int { + return 0 + }) +} diff --git a/pkg/golinters/exptostd/testdata/fix/in/exptostd.go b/pkg/golinters/exptostd/testdata/fix/in/exptostd.go new file mode 100644 index 000000000000..d9642737dd58 --- /dev/null +++ b/pkg/golinters/exptostd/testdata/fix/in/exptostd.go @@ -0,0 +1,113 @@ +//golangcitest:args -Eexptostd +package testdata + +import ( + "fmt" + + "golang.org/x/exp/maps" // want `Import statement 'golang.org/x/exp/maps' can be replaced by 'maps'` + "golang.org/x/exp/slices" // want `Import statement 'golang.org/x/exp/slices' can be replaced by 'slices'` +) + +func _(m, a map[string]string) { + maps.Clone(m) // want `golang.org/x/exp/maps.Clone\(\) can be replaced by maps.Clone\(\)` + + maps.Equal(m, a) // want `golang.org/x/exp/maps.Equal\(\) can be replaced by maps.Equal\(\)` + + maps.EqualFunc(m, a, func(i, j string) bool { // want `golang.org/x/exp/maps.EqualFunc\(\) can be replaced by maps.EqualFunc\(\)` + return true + }) + + maps.Copy(m, a) // want `golang.org/x/exp/maps.Copy\(\) can be replaced by maps.Copy\(\)` + + maps.DeleteFunc(m, func(_, _ string) bool { // want `golang.org/x/exp/maps.DeleteFunc\(\) can be replaced by maps.DeleteFunc\(\)` + return true + }) + + maps.Clear(m) // want `golang.org/x/exp/maps.Clear\(\) can be replaced by clear\(\)` + + fmt.Println("Hello") +} + +func _(a, b []string) { + slices.Equal(a, b) + + slices.EqualFunc(a, b, func(_ string, _ string) bool { + return true + }) + + slices.Compare(a, b) + + slices.CompareFunc(a, b, func(_ string, _ string) int { + return 0 + }) + + slices.Index(a, "a") + + slices.IndexFunc(a, func(_ string) bool { + return true + }) + + slices.Contains(a, "a") + + slices.ContainsFunc(a, func(_ string) bool { + return true + }) + + slices.Insert(a, 0, "a", "b") + + slices.Delete(a, 0, 1) + + slices.DeleteFunc(a, func(_ string) bool { + return true + }) + + slices.Replace(a, 0, 1, "a") + + slices.Clone(a) + + slices.Compact(a) + + slices.CompactFunc(a, func(_ string, _ string) bool { + return true + }) + + slices.Grow(a, 2) + + slices.Clip(a) + + slices.Reverse(a) + + slices.Sort(a) + + slices.SortFunc(a, func(_, _ string) int { + return 0 + }) + + slices.SortStableFunc(a, func(_, _ string) int { + return 0 + }) + + slices.IsSorted(a) + + slices.IsSortedFunc(a, func(_, _ string) int { + return 0 + }) + + slices.Min(a) + + slices.MinFunc(a, func(_, _ string) int { + return 0 + }) + + slices.Max(a) + + slices.MaxFunc(a, func(_, _ string) int { + return 0 + }) + + slices.BinarySearch(a, "a") + + slices.BinarySearchFunc(a, b, func(_ string, _ []string) int { + return 0 + }) +} diff --git a/pkg/golinters/exptostd/testdata/fix/out/exptostd.go b/pkg/golinters/exptostd/testdata/fix/out/exptostd.go new file mode 100644 index 000000000000..5ebf6d5900f8 --- /dev/null +++ b/pkg/golinters/exptostd/testdata/fix/out/exptostd.go @@ -0,0 +1,113 @@ +//golangcitest:args -Eexptostd +package testdata + +import ( + "fmt" + + "maps" // want `Import statement 'golang.org/x/exp/maps' can be replaced by 'maps'` + "slices" // want `Import statement 'golang.org/x/exp/slices' can be replaced by 'slices'` +) + +func _(m, a map[string]string) { + maps.Clone(m) // want `golang.org/x/exp/maps.Clone\(\) can be replaced by maps.Clone\(\)` + + maps.Equal(m, a) // want `golang.org/x/exp/maps.Equal\(\) can be replaced by maps.Equal\(\)` + + maps.EqualFunc(m, a, func(i, j string) bool { // want `golang.org/x/exp/maps.EqualFunc\(\) can be replaced by maps.EqualFunc\(\)` + return true + }) + + maps.Copy(m, a) // want `golang.org/x/exp/maps.Copy\(\) can be replaced by maps.Copy\(\)` + + maps.DeleteFunc(m, func(_, _ string) bool { // want `golang.org/x/exp/maps.DeleteFunc\(\) can be replaced by maps.DeleteFunc\(\)` + return true + }) + + clear(m) // want `golang.org/x/exp/maps.Clear\(\) can be replaced by clear\(\)` + + fmt.Println("Hello") +} + +func _(a, b []string) { + slices.Equal(a, b) + + slices.EqualFunc(a, b, func(_ string, _ string) bool { + return true + }) + + slices.Compare(a, b) + + slices.CompareFunc(a, b, func(_ string, _ string) int { + return 0 + }) + + slices.Index(a, "a") + + slices.IndexFunc(a, func(_ string) bool { + return true + }) + + slices.Contains(a, "a") + + slices.ContainsFunc(a, func(_ string) bool { + return true + }) + + slices.Insert(a, 0, "a", "b") + + slices.Delete(a, 0, 1) + + slices.DeleteFunc(a, func(_ string) bool { + return true + }) + + slices.Replace(a, 0, 1, "a") + + slices.Clone(a) + + slices.Compact(a) + + slices.CompactFunc(a, func(_ string, _ string) bool { + return true + }) + + slices.Grow(a, 2) + + slices.Clip(a) + + slices.Reverse(a) + + slices.Sort(a) + + slices.SortFunc(a, func(_, _ string) int { + return 0 + }) + + slices.SortStableFunc(a, func(_, _ string) int { + return 0 + }) + + slices.IsSorted(a) + + slices.IsSortedFunc(a, func(_, _ string) int { + return 0 + }) + + slices.Min(a) + + slices.MinFunc(a, func(_, _ string) int { + return 0 + }) + + slices.Max(a) + + slices.MaxFunc(a, func(_, _ string) int { + return 0 + }) + + slices.BinarySearch(a, "a") + + slices.BinarySearchFunc(a, b, func(_ string, _ []string) int { + return 0 + }) +} diff --git a/pkg/golinters/exptostd/testdata/go.mod b/pkg/golinters/exptostd/testdata/go.mod new file mode 100644 index 000000000000..5261142a3036 --- /dev/null +++ b/pkg/golinters/exptostd/testdata/go.mod @@ -0,0 +1,5 @@ +module exptostd + +go 1.22.0 + +require golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 diff --git a/pkg/golinters/exptostd/testdata/go.sum b/pkg/golinters/exptostd/testdata/go.sum new file mode 100644 index 000000000000..c487fae960b3 --- /dev/null +++ b/pkg/golinters/exptostd/testdata/go.sum @@ -0,0 +1,2 @@ +golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 h1:1UoZQm6f0P/ZO0w1Ri+f+ifG/gXhegadRdwBIXEFWDo= +golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67/go.mod h1:qj5a5QZpwLU2NLQudwIN5koi3beDhSAlJwa67PuM98c= diff --git a/pkg/lint/lintersdb/builder_linter.go b/pkg/lint/lintersdb/builder_linter.go index 8f149117fb75..4338aa88ccf9 100644 --- a/pkg/lint/lintersdb/builder_linter.go +++ b/pkg/lint/lintersdb/builder_linter.go @@ -26,6 +26,7 @@ import ( "github.com/golangci/golangci-lint/pkg/golinters/exhaustive" "github.com/golangci/golangci-lint/pkg/golinters/exhaustruct" "github.com/golangci/golangci-lint/pkg/golinters/exportloopref" + "github.com/golangci/golangci-lint/pkg/golinters/exptostd" "github.com/golangci/golangci-lint/pkg/golinters/fatcontext" "github.com/golangci/golangci-lint/pkg/golinters/forbidigo" "github.com/golangci/golangci-lint/pkg/golinters/forcetypeassert" @@ -283,6 +284,13 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithURL("https://github.com/kyoh86/exportloopref"). DeprecatedWarning("Since Go1.22 (loopvar) this linter is no longer relevant.", "v1.60.2", "copyloopvar"), + linter.NewConfig(exptostd.New()). + WithSince("v1.63.0"). + WithPresets(linter.PresetStyle). + WithLoadForGoAnalysis(). + WithAutoFix(). + WithURL("https://github.com/ldez/exptostd"), + linter.NewConfig(forbidigo.New(&cfg.LintersSettings.Forbidigo)). WithSince("v1.34.0"). WithPresets(linter.PresetStyle).