diff options
| author | Russ Cox <rsc@golang.org> | 2023-01-13 10:21:56 -0500 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2023-01-17 22:30:23 +0000 |
| commit | 6bb003d0323648d5f11689dab40ba4b158d7d6b4 (patch) | |
| tree | 0608a999712afa34bf1e02df7fa417a02e6dee10 /src/internal/goroot | |
| parent | f773bef9ab837db1bd81df375a701196b23ac510 (diff) | |
| download | go-6bb003d0323648d5f11689dab40ba4b158d7d6b4.tar.xz | |
cmd/go: do not confuse files for standard library packages
I often create dummy files holding various data named things like 'z'.
If a file (not directory) GOROOT/src/z exists, it confuses cmd/go into
thinking z is a standard library package, which breaks the test
Script/mod_vendor.
This CL fixes internal/goroot to only report that something is a standard
library package when a directory with that name exists, not just a file.
Change-Id: I986c9a425e78d23c7e033aeadb8e9f71aab2b878
Reviewed-on: https://go-review.googlesource.com/c/go/+/461955
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/internal/goroot')
| -rw-r--r-- | src/internal/goroot/gc.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/internal/goroot/gc.go b/src/internal/goroot/gc.go index 79403d29fc..c0216f4ea5 100644 --- a/src/internal/goroot/gc.go +++ b/src/internal/goroot/gc.go @@ -20,8 +20,8 @@ func IsStandardPackage(goroot, compiler, path string) bool { switch compiler { case "gc": dir := filepath.Join(goroot, "src", path) - _, err := os.Stat(dir) - return err == nil + info, err := os.Stat(dir) + return err == nil && info.IsDir() case "gccgo": return gccgoSearch.isStandard(path) default: |
