Skip to content

Commit

Permalink
cmd/internal/testdir: use os.ReadDir
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
kolyshkin authored and gopherbot committed Sep 6, 2024
1 parent 29a3a39 commit 46bccde
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/cmd/internal/testdir/testdir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 46bccde

Please sign in to comment.