-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
671 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
//golangcitest:args -Eexptostd | ||
package testdata | ||
|
||
/* | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
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 | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
}) | ||
} |
Oops, something went wrong.