mirror of
https://github.com/golang/go
synced 2024-11-16 19:14:43 -07:00
go/build: remove two erroneous uses of os.Stat
go/build should use the ctxt routines, not os directly. These snuck in. Change-Id: I918d4de923eb485bfd524e4f1b1310a7a165ad03 Reviewed-on: https://go-review.googlesource.com/c/go/+/266357 Trust: Russ Cox <rsc@golang.org> Trust: Jay Conrod <jayconrod@google.com> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
This commit is contained in:
parent
09d5e0d119
commit
9a1596689e
@ -805,7 +805,7 @@ Found:
|
||||
continue
|
||||
}
|
||||
if d.Mode()&fs.ModeSymlink != 0 {
|
||||
if fi, err := os.Stat(filepath.Join(p.Dir, d.Name())); err == nil && fi.IsDir() {
|
||||
if ctxt.isDir(ctxt.joinPath(p.Dir, d.Name())) {
|
||||
// Symlinks to directories are not source files.
|
||||
continue
|
||||
}
|
||||
@ -1117,9 +1117,14 @@ func (ctxt *Context) importGo(p *Package, path, srcDir string, mode ImportMode)
|
||||
}
|
||||
}
|
||||
for {
|
||||
info, err := os.Stat(filepath.Join(parent, "go.mod"))
|
||||
if err == nil && !info.IsDir() {
|
||||
break
|
||||
if f, err := ctxt.openFile(ctxt.joinPath(parent, "go.mod")); err == nil {
|
||||
buf := make([]byte, 100)
|
||||
_, err := f.Read(buf)
|
||||
f.Close()
|
||||
if err == nil || err == io.EOF {
|
||||
// go.mod exists and is readable (is a file, not a directory).
|
||||
break
|
||||
}
|
||||
}
|
||||
d := filepath.Dir(parent)
|
||||
if len(d) >= len(parent) {
|
||||
|
Loading…
Reference in New Issue
Block a user