]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: replace some more stats with fsys.Stat
authorMichael Matloob <matloob@golang.org>
Thu, 22 Oct 2020 22:06:54 +0000 (18:06 -0400)
committerMichael Matloob <matloob@golang.org>
Fri, 23 Oct 2020 19:36:38 +0000 (19:36 +0000)
To support overlays

For #39958

Change-Id: I5ffd72aeb7f5f30f6c60f6334a01a0a1383c7945
Reviewed-on: https://go-review.googlesource.com/c/go/+/264478
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/go/internal/imports/scan.go
src/cmd/go/internal/modload/load.go
src/cmd/go/internal/modload/search.go
src/cmd/go/internal/search/search.go

index d7e674b129e62314c88c5628ea38b4b258ef1463..ee11a8708b5eaa26c904bbb41477c19aa773e136 100644 (file)
@@ -7,7 +7,6 @@ package imports
 import (
        "fmt"
        "io/fs"
-       "os"
        "path/filepath"
        "sort"
        "strconv"
@@ -28,7 +27,7 @@ func ScanDir(dir string, tags map[string]bool) ([]string, []string, error) {
                // If the directory entry is a symlink, stat it to obtain the info for the
                // link target instead of the link itself.
                if info.Mode()&fs.ModeSymlink != 0 {
-                       info, err = os.Stat(filepath.Join(dir, name))
+                       info, err = fsys.Stat(filepath.Join(dir, name))
                        if err != nil {
                                continue // Ignore broken symlinks.
                        }
index 4b3ded83266b8fe4893bdc65433ffd0f6c8a8b9f..4611fc7f6e5eda86e1041de4e9b9e6ad19da2df6 100644 (file)
@@ -112,6 +112,7 @@ import (
 
        "cmd/go/internal/base"
        "cmd/go/internal/cfg"
+       "cmd/go/internal/fsys"
        "cmd/go/internal/imports"
        "cmd/go/internal/modfetch"
        "cmd/go/internal/mvs"
@@ -361,7 +362,7 @@ func resolveLocalPackage(dir string) (string, error) {
                // If the named directory does not exist or contains no Go files,
                // the package does not exist.
                // Other errors may affect package loading, but not resolution.
-               if _, err := os.Stat(absDir); err != nil {
+               if _, err := fsys.Stat(absDir); err != nil {
                        if os.IsNotExist(err) {
                                // Canonicalize OS-specific errors to errDirectoryNotFound so that error
                                // messages will be easier for users to search for.
index 19289ceb9ce3e07d8c838ecf86ebb273e8ddeb16..be4cb7e745a44a8760f087aae822f77b245f452e 100644 (file)
@@ -87,7 +87,7 @@ func matchPackages(ctx context.Context, m *search.Match, tags map[string]bool, f
 
                        if !fi.IsDir() {
                                if fi.Mode()&fs.ModeSymlink != 0 && want {
-                                       if target, err := os.Stat(path); err == nil && target.IsDir() {
+                                       if target, err := fsys.Stat(path); err == nil && target.IsDir() {
                                                fmt.Fprintf(os.Stderr, "warning: ignoring symlink %s\n", path)
                                        }
                                }
index e4784e94783a07f03d993b15b5edbb25c2716aef..57cbb282a8b1ed8360022ac85f85686df3b15169 100644 (file)
@@ -156,7 +156,7 @@ func (m *Match) MatchPackages() {
 
                        if !fi.IsDir() {
                                if fi.Mode()&fs.ModeSymlink != 0 && want {
-                                       if target, err := os.Stat(path); err == nil && target.IsDir() {
+                                       if target, err := fsys.Stat(path); err == nil && target.IsDir() {
                                                fmt.Fprintf(os.Stderr, "warning: ignoring symlink %s\n", path)
                                        }
                                }