From: qiulaidongfeng <2645477756@qq.com> Date: Wed, 29 Nov 2023 12:45:01 +0000 (+0000) Subject: cmd/internal/moddeps: walk GOROOT when it is a symlink X-Git-Tag: go1.22rc1~140 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=1908d4354b5b1cb02edd9f93d024551fe812eb22;p=gostls13.git 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 Reviewed-by: Bryan Mills TryBot-Result: Gopher Robot Run-TryBot: Bryan Mills Reviewed-by: Dmitri Shuralyov --- 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 }