]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/moddeps: walk GOROOT when it is a symlink
authorqiulaidongfeng <2645477756@qq.com>
Wed, 29 Nov 2023 12:45:01 +0000 (12:45 +0000)
committerGopher Robot <gobot@golang.org>
Wed, 29 Nov 2023 15:49:32 +0000 (15:49 +0000)
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>
src/cmd/internal/moddeps/moddeps_test.go

index ae890b66cb479cb848f0a12149df8c954f3caca5..3d4c99eecb46baee7c87a18601c7717f17318670 100644 (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
                        }