1
0
mirror of https://github.com/golang/go synced 2024-11-23 17:50:06 -07:00

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 <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>
This commit is contained in:
Michael Matloob 2020-10-22 18:06:54 -04:00
parent c3fe874f25
commit 3931cc113f
4 changed files with 5 additions and 5 deletions

View 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.
}

View 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.

View 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)
}
}

View 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)
}
}