1
0
mirror of https://github.com/golang/go synced 2024-11-23 00:20:12 -07:00

cmd/internal/moddeps: walk GOROOT when it is a symlink

Fixes #64375

Change-Id: I24ce67ef254db447cdf37a3fda5b5ab5fc782a36
GitHub-Last-Rev: 05590b9e20
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>
This commit is contained in:
qiulaidongfeng 2023-11-29 12:45:01 +00:00 committed by Gopher Robot
parent 6111acc8e6
commit 1908d4354b

View File

@ -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
}