Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: build tags not honored using ./... with go build, list, and test #11246

Closed
stevvooe opened this issue Jun 17, 2015 · 3 comments
Closed
Milestone

Comments

@stevvooe
Copy link

The commands go build, go list and go test do not honor the build tags unless the full package path is specified. The issue occurs when using a command in the form go list ./... and one of the packages has all of the files guarded by build tags. With or without the -tags argument provided, the command fails to build, test or run the target package. If the full package path is provided, it works as expected.

Rather than try to describe all the steps to reproduce the issue, I've made a package available here to demonstrate. The README contains full instructions.

This behavior was observed on go1.4.2 on Mac OS X 10.10.

@ianlancetaylor ianlancetaylor changed the title build tags not honored using ./... with go build, list, and test cmd/go: build tags not honored using ./... with go build, list, and test Jun 17, 2015
@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Jun 17, 2015
@albhaf
Copy link

albhaf commented Jun 20, 2015

Reproduced on tip.

The following appears to fix the issue and passes all.bash:

diff --git a/src/cmd/go/main.go b/src/cmd/go/main.go
index 1bd7540..be002e1 100644
--- a/src/cmd/go/main.go
+++ b/src/cmd/go/main.go
@@ -624,7 +624,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)
                        }

@bradfitz
Copy link
Contributor

/cc @rsc for cmd/go

@gopherbot
Copy link

CL https://golang.org/cl/17942 mentions this issue.

@rsc rsc closed this as completed in 70cee78 Dec 17, 2015
@golang golang locked and limited conversation to collaborators Dec 29, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants