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
go/build: build.Import finds empty directories as packages #16898
Comments
An empty directory is not a package. Quoth ref/spec: "A package in turn is constructed from one or more source files" I'm going to close this as WAI. Was there a particular reason you expected it to find the empty bar directory? |
But when bar directory is in $GOPATH/src, build.Import finds bar and returned err is nil. |
That does seem odd, I agree. The behavior seems to match the documentation, though. This is also covered in the vendoring spec: https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo/edit
So if anything, the bug is that build.Import /does/ find the non-vendored directory. /cc @rsc Is this WAI? |
I spoke to @rsc about this and it is WAI. build.Import finds empty directories because it might be used to figure out where a package "should" live (e.g. so that you can then place files in that directory). Whereas it does not find empty directories in vendor/ because they would shadow non-vendored non-empty directories. For example, if you vendor Again, is there a particular place where you feel this logic breaks something? |
Please answer these questions before submitting your issue. Thanks!
go version
)?go env
)?nothing
The text was updated successfully, but these errors were encountered: