mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/internal/testdir: use os.ReadDir
Change-Id: I9828c7c4f9c27efabf072ec1d83b3ce94c14cc0f Reviewed-on: https://go-review.googlesource.com/c/go/+/610817 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
This commit is contained in:
parent
29a3a39b61
commit
46bccdebfa
1 changed files with 3 additions and 8 deletions
|
|
@ -162,22 +162,17 @@ func shardMatch(name string) bool {
|
|||
}
|
||||
|
||||
func goFiles(t *testing.T, dir string) []string {
|
||||
f, err := os.Open(filepath.Join(testenv.GOROOT(t), "test", dir))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
dirnames, err := f.Readdirnames(-1)
|
||||
f.Close()
|
||||
files, err := os.ReadDir(filepath.Join(testenv.GOROOT(t), "test", dir))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
names := []string{}
|
||||
for _, name := range dirnames {
|
||||
for _, file := range files {
|
||||
name := file.Name()
|
||||
if !strings.HasPrefix(name, ".") && strings.HasSuffix(name, ".go") && shardMatch(name) {
|
||||
names = append(names, name)
|
||||
}
|
||||
}
|
||||
sort.Strings(names)
|
||||
return names
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue