aboutsummaryrefslogtreecommitdiff
path: root/src/internal
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2020-10-29 14:46:29 -0400
committerRuss Cox <rsc@golang.org>2020-12-09 19:12:27 +0000
commitf1980efb92c011eab71aa61b68ccf58d845d1de7 (patch)
tree8bfed500207b38cba5fc254c2531a9760d6a0154 /src/internal
parent4f1b0a44cb46f3df28f5ef82e5769ebeac1bc493 (diff)
downloadgo-f1980efb92c011eab71aa61b68ccf58d845d1de7.tar.gz
go-f1980efb92c011eab71aa61b68ccf58d845d1de7.zip
all: update to use os.ReadDir where appropriate
os.ReadDir is a replacement for ioutil.ReadDir that returns a slice of fs.DirEntry instead of fs.FileInfo, meaning it is the more efficient form. This CL updates call sites throughout the Go source tree wherever possible. As usual, code built using the Go 1.4 bootstrap toolchain is not included. There is also a use in go/build that appears in the public API and can't be changed, at least not without additional changes. Fixes #42026. Change-Id: Icfc9dd52c6045020f6830e22c72128499462d561 Reviewed-on: https://go-review.googlesource.com/c/go/+/266366 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/internal')
-rw-r--r--src/internal/trace/parser_test.go7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/internal/trace/parser_test.go b/src/internal/trace/parser_test.go
index 316220cfa8..cdab95a59e 100644
--- a/src/internal/trace/parser_test.go
+++ b/src/internal/trace/parser_test.go
@@ -6,7 +6,6 @@ package trace
import (
"bytes"
- "io/ioutil"
"os"
"path/filepath"
"strings"
@@ -34,19 +33,19 @@ func TestCorruptedInputs(t *testing.T) {
}
func TestParseCanned(t *testing.T) {
- files, err := ioutil.ReadDir("./testdata")
+ files, err := os.ReadDir("./testdata")
if err != nil {
t.Fatalf("failed to read ./testdata: %v", err)
}
for _, f := range files {
- name := filepath.Join("./testdata", f.Name())
- info, err := os.Stat(name)
+ info, err := f.Info()
if err != nil {
t.Fatal(err)
}
if testing.Short() && info.Size() > 10000 {
continue
}
+ name := filepath.Join("./testdata", f.Name())
data, err := os.ReadFile(name)
if err != nil {
t.Fatal(err)