]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: use tags when evaluating file system wildcards like ./...
authorRuss Cox <rsc@golang.org>
Thu, 17 Dec 2015 03:52:00 +0000 (22:52 -0500)
committerRuss Cox <rsc@golang.org>
Thu, 17 Dec 2015 05:46:29 +0000 (05:46 +0000)
Thanks to Albert Hafvenström for the diagnosis.

Fixes #11246.

Change-Id: I2b9e670c0ecf6aa01e5bf4d7a402619e93cc4f4a
Reviewed-on: https://go-review.googlesource.com/17942
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/go/go_test.go
src/cmd/go/main.go

index 167b6c2fc2eb29125ca8b2e157e74355508ba9e3..49fdd532309b4dd57030f3f6353c0a56053185c8 100644 (file)
@@ -781,6 +781,16 @@ func TestGoInstallDetectsRemovedFiles(t *testing.T) {
        tg.wantStale("mypkg", "./testgo list mypkg claims mypkg is NOT stale after removing y.go; should be stale")
 }
 
+func TestGoListWithTags(t *testing.T) {
+       tg := testgo(t)
+       defer tg.cleanup()
+       tg.tempFile("src/mypkg/x.go", "// +build thetag\n\npackage mypkg\n")
+       tg.setenv("GOPATH", tg.path("."))
+       tg.cd(tg.path("./src"))
+       tg.run("list", "-tags=thetag", "./my...")
+       tg.grepStdout("mypkg", "did not find mypkg")
+}
+
 func TestGoInstallErrorOnCrossCompileToBin(t *testing.T) {
        if testing.Short() {
                t.Skip("don't install into GOROOT in short mode")
index ca0ce82082c5a2a49ff69fb19f38c3c8d3c1df0b..43a51404e67854866498a50e8feb9f5a0fcf3726 100644 (file)
@@ -674,7 +674,7 @@ func matchPackagesInFS(pattern string) []string {
                if !match(name) {
                        return nil
                }
-               if _, err = build.ImportDir(path, 0); err != nil {
+               if _, err = buildContext.ImportDir(path, 0); err != nil {
                        if _, noGo := err.(*build.NoGoError); !noGo {
                                log.Print(err)
                        }