Skip to content

Commit 3931cc1

Browse files
committed
cmd/go: replace some more stats with fsys.Stat
To support overlays For #39958 Change-Id: I5ffd72aeb7f5f30f6c60f6334a01a0a1383c7945 Reviewed-on: https://go-review.googlesource.com/c/go/+/264478 Trust: Michael Matloob <[email protected]> Run-TryBot: Michael Matloob <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
1 parent c3fe874 commit 3931cc1

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

src/cmd/go/internal/imports/scan.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ package imports
77
import (
88
"fmt"
99
"io/fs"
10-
"os"
1110
"path/filepath"
1211
"sort"
1312
"strconv"
@@ -28,7 +27,7 @@ func ScanDir(dir string, tags map[string]bool) ([]string, []string, error) {
2827
// If the directory entry is a symlink, stat it to obtain the info for the
2928
// link target instead of the link itself.
3029
if info.Mode()&fs.ModeSymlink != 0 {
31-
info, err = os.Stat(filepath.Join(dir, name))
30+
info, err = fsys.Stat(filepath.Join(dir, name))
3231
if err != nil {
3332
continue // Ignore broken symlinks.
3433
}

src/cmd/go/internal/modload/load.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ import (
112112

113113
"cmd/go/internal/base"
114114
"cmd/go/internal/cfg"
115+
"cmd/go/internal/fsys"
115116
"cmd/go/internal/imports"
116117
"cmd/go/internal/modfetch"
117118
"cmd/go/internal/mvs"
@@ -361,7 +362,7 @@ func resolveLocalPackage(dir string) (string, error) {
361362
// If the named directory does not exist or contains no Go files,
362363
// the package does not exist.
363364
// Other errors may affect package loading, but not resolution.
364-
if _, err := os.Stat(absDir); err != nil {
365+
if _, err := fsys.Stat(absDir); err != nil {
365366
if os.IsNotExist(err) {
366367
// Canonicalize OS-specific errors to errDirectoryNotFound so that error
367368
// messages will be easier for users to search for.

src/cmd/go/internal/modload/search.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func matchPackages(ctx context.Context, m *search.Match, tags map[string]bool, f
8787

8888
if !fi.IsDir() {
8989
if fi.Mode()&fs.ModeSymlink != 0 && want {
90-
if target, err := os.Stat(path); err == nil && target.IsDir() {
90+
if target, err := fsys.Stat(path); err == nil && target.IsDir() {
9191
fmt.Fprintf(os.Stderr, "warning: ignoring symlink %s\n", path)
9292
}
9393
}

src/cmd/go/internal/search/search.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func (m *Match) MatchPackages() {
156156

157157
if !fi.IsDir() {
158158
if fi.Mode()&fs.ModeSymlink != 0 && want {
159-
if target, err := os.Stat(path); err == nil && target.IsDir() {
159+
if target, err := fsys.Stat(path); err == nil && target.IsDir() {
160160
fmt.Fprintf(os.Stderr, "warning: ignoring symlink %s\n", path)
161161
}
162162
}

0 commit comments

Comments
 (0)