aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal
diff options
context:
space:
mode:
authorqiulaidongfeng <2645477756@qq.com>2023-11-29 12:45:01 +0000
committerGopher Robot <gobot@golang.org>2023-11-29 15:49:32 +0000
commit1908d4354b5b1cb02edd9f93d024551fe812eb22 (patch)
tree5940cf91857742dac8d7a5ab6888f4532983ecbe /src/cmd/internal
parent6111acc8e6bc96f5ca0fa58adf4a0226fff3dd28 (diff)
downloadgo-1908d4354b5b1cb02edd9f93d024551fe812eb22.tar.xz
cmd/internal/moddeps: walk GOROOT when it is a symlink
Fixes #64375 Change-Id: I24ce67ef254db447cdf37a3fda5b5ab5fc782a36 GitHub-Last-Rev: 05590b9e20b31413d455a6e87bc38843e33ff116 GitHub-Pull-Request: golang/go#64376 Reviewed-on: https://go-review.googlesource.com/c/go/+/544757 Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Diffstat (limited to 'src/cmd/internal')
-rw-r--r--src/cmd/internal/moddeps/moddeps_test.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/cmd/internal/moddeps/moddeps_test.go b/src/cmd/internal/moddeps/moddeps_test.go
index ae890b66cb..3d4c99eecb 100644
--- a/src/cmd/internal/moddeps/moddeps_test.go
+++ b/src/cmd/internal/moddeps/moddeps_test.go
@@ -443,7 +443,14 @@ func findGorootModules(t *testing.T) []gorootModule {
goBin := testenv.GoToolPath(t)
goroot.once.Do(func() {
- goroot.err = filepath.WalkDir(testenv.GOROOT(t), func(path string, info fs.DirEntry, err error) error {
+ // If the root itself is a symlink to a directory,
+ // we want to follow it (see https://go.dev/issue/64375).
+ // Add a trailing separator to force that to happen.
+ root := testenv.GOROOT(t)
+ if !os.IsPathSeparator(root[len(root)-1]) {
+ root += string(filepath.Separator)
+ }
+ goroot.err = filepath.WalkDir(root, func(path string, info fs.DirEntry, err error) error {
if err != nil {
return err
}