Skip to content

Commit 70cee78

Browse files
committed
cmd/go: use tags when evaluating file system wildcards like ./...
Thanks to Albert Hafvenström for the diagnosis. Fixes golang#11246. Change-Id: I2b9e670c0ecf6aa01e5bf4d7a402619e93cc4f4a Reviewed-on: https://go-review.googlesource.com/17942 Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 37f2afa commit 70cee78

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/cmd/go/go_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,16 @@ func TestGoInstallDetectsRemovedFiles(t *testing.T) {
781781
tg.wantStale("mypkg", "./testgo list mypkg claims mypkg is NOT stale after removing y.go; should be stale")
782782
}
783783

784+
func TestGoListWithTags(t *testing.T) {
785+
tg := testgo(t)
786+
defer tg.cleanup()
787+
tg.tempFile("src/mypkg/x.go", "// +build thetag\n\npackage mypkg\n")
788+
tg.setenv("GOPATH", tg.path("."))
789+
tg.cd(tg.path("./src"))
790+
tg.run("list", "-tags=thetag", "./my...")
791+
tg.grepStdout("mypkg", "did not find mypkg")
792+
}
793+
784794
func TestGoInstallErrorOnCrossCompileToBin(t *testing.T) {
785795
if testing.Short() {
786796
t.Skip("don't install into GOROOT in short mode")

src/cmd/go/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ func matchPackagesInFS(pattern string) []string {
674674
if !match(name) {
675675
return nil
676676
}
677-
if _, err = build.ImportDir(path, 0); err != nil {
677+
if _, err = buildContext.ImportDir(path, 0); err != nil {
678678
if _, noGo := err.(*build.NoGoError); !noGo {
679679
log.Print(err)
680680
}

0 commit comments

Comments
 (0)