]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: don't let ... match GOROOT/src/cmd in module mode
authorRuss Cox <rsc@golang.org>
Fri, 10 Aug 2018 19:25:15 +0000 (15:25 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 10 Aug 2018 20:02:31 +0000 (20:02 +0000)
GOROOT/src/cmd uses GOROOT/src/cmd/vendor, which module
mode simply cannot handle.

Exposed by making ... match the standard library, which it still should.

But for now it's fine to just exclude commands.

Change-Id: I2201b94445f11239022de8a2473aa3b573f405c0
Reviewed-on: https://go-review.googlesource.com/129055
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/go/internal/modload/search.go
src/cmd/go/testdata/script/mod_patterns.txt

index 6aaabe6a08760fe1db3a58eed5a6960f8f0bf8f4..24825cc35d8a373582a28d1c9c8895cc2c54464f 100644 (file)
@@ -37,6 +37,10 @@ func matchPackages(pattern string, tags map[string]bool, useStd bool, modules []
 
        walkPkgs := func(root, importPathRoot string) {
                root = filepath.Clean(root)
+               var cmd string
+               if root == cfg.GOROOTsrc {
+                       cmd = filepath.Join(root, "cmd")
+               }
                filepath.Walk(root, func(path string, fi os.FileInfo, err error) error {
                        if err != nil {
                                return nil
@@ -47,6 +51,14 @@ func matchPackages(pattern string, tags map[string]bool, useStd bool, modules []
                                return nil
                        }
 
+                       // GOROOT/src/cmd makes use of GOROOT/src/cmd/vendor,
+                       // which module mode can't deal with. Eventually we'll stop using
+                       // that vendor directory, and then we can remove this exclusion.
+                       // golang.org/issue/26924.
+                       if path == cmd {
+                               return filepath.SkipDir
+                       }
+
                        want := true
                        // Avoid .foo, _foo, and testdata directory trees.
                        _, elem := filepath.Split(path)
index 2a3629f764e5470a170d45c6fbe65ee0f9ef6485..36d738a867df1de76e2dd607a18dd49f7a062981 100644 (file)
@@ -15,6 +15,7 @@ stdout '^unsafe$'
 ! stdout index/suffixarray
 
 # 'go list ...' should list packages in all active modules and the standard library.
+# But not cmd/* - see golang.org/issue/26924.
 go list ...
 stdout example.com/unused/useerrors
 stdout example.com/m/useunsafe
@@ -23,6 +24,7 @@ stdout example.com/m/useunsafe
 stdout '^unicode$'
 stdout '^unsafe$'
 stdout index/suffixarray
+! stdout cmd/pprof
 
 # 'go list example.com/m/...' should list packages in all modules that begin with
 # "example.com/m/".