Skip to content

Commit 05590b9

Browse files
fix
1 parent 85a4de2 commit 05590b9

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

src/cmd/internal/moddeps/moddeps_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,14 @@ func findGorootModules(t *testing.T) []gorootModule {
443443
goBin := testenv.GoToolPath(t)
444444

445445
goroot.once.Do(func() {
446-
goroot.err = filepath.WalkDir(testenv.GOROOT(t), func(path string, info fs.DirEntry, err error) error {
446+
// If the root itself is a symlink to a directory,
447+
// we want to follow it (see https://go.dev/issue/64375).
448+
// Add a trailing separator to force that to happen.
449+
root := testenv.GOROOT(t)
450+
if !os.IsPathSeparator(root[len(root)-1]) {
451+
root += string(filepath.Separator)
452+
}
453+
goroot.err = filepath.WalkDir(root, func(path string, info fs.DirEntry, err error) error {
447454
if err != nil {
448455
return err
449456
}

src/internal/testenv/testenv.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -252,20 +252,6 @@ func findGOROOT() (string, error) {
252252
}
253253
})
254254

255-
info, err := os.Lstat(gorootPath)
256-
if err != nil {
257-
return "", err
258-
}
259-
if info.Mode()&os.ModeSymlink != 0 {
260-
gorootPath, err = os.Readlink(gorootPath)
261-
if err != nil {
262-
return "", err
263-
}
264-
}
265-
if err != nil {
266-
return "", err
267-
}
268-
os.Setenv("GOROOT", gorootPath)
269255
return gorootPath, gorootErr
270256
}
271257

0 commit comments

Comments
 (0)