Skip to content

Commit eda2f3c

Browse files
committed
godoc/vfs/os.go, internal/imports/fix.go:
replace deprecated ioutil.ReadDir with internal buildutil.GetFileInfos
1 parent 4989088 commit eda2f3c

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

godoc/vfs/os.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ package vfs
77
import (
88
"fmt"
99
"go/build"
10-
"io/ioutil"
1110
"os"
1211
pathpkg "path"
1312
"path/filepath"
1413
"runtime"
1514
"slices"
15+
16+
"golang.org/x/tools/go/buildutil"
1617
)
1718

1819
// We expose a new variable because otherwise we need to copy the findGOROOT logic again
@@ -100,5 +101,5 @@ func (root osFS) Stat(path string) (os.FileInfo, error) {
100101
}
101102

102103
func (root osFS) ReadDir(path string) ([]os.FileInfo, error) {
103-
return ioutil.ReadDir(root.resolve(path)) // is sorted
104+
return buildutil.GetFileInfos(root.resolve(path)) // is sorted
104105
}

internal/imports/fix.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
"go/token"
1616
"go/types"
1717
"io/fs"
18-
"io/ioutil"
1918
"os"
2019
"path"
2120
"path/filepath"
@@ -30,6 +29,7 @@ import (
3029
"maps"
3130

3231
"golang.org/x/tools/go/ast/astutil"
32+
"golang.org/x/tools/go/buildutil"
3333
"golang.org/x/tools/internal/event"
3434
"golang.org/x/tools/internal/gocommand"
3535
"golang.org/x/tools/internal/gopathwalk"
@@ -1081,7 +1081,7 @@ func (e *ProcessEnv) buildContext() (*build.Context, error) {
10811081
// HACK: setting any of the Context I/O hooks prevents Import from invoking
10821082
// 'go list', regardless of GO111MODULE. This is undocumented, but it's
10831083
// unlikely to change before GOPATH support is removed.
1084-
ctx.ReadDir = ioutil.ReadDir
1084+
ctx.ReadDir = buildutil.GetFileInfos
10851085

10861086
return &ctx, nil
10871087
}

0 commit comments

Comments
 (0)