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: vendored x/y cannot import unvendored x/internal/z #16622
Comments
I'm sorry, you cannot use "internal" as a name for a repository. Sorry this On Sat, Aug 6, 2016 at 5:51 AM, Sean Hagen notifications@github.com wrote:
|
@davecheney is there a reason for this? I thought based on the way the doc I found was written, it didn't matter where 'internal' was in the chain of the package name. Is it just a weird edge case where vendoring and internal packages don't play nice that's not easy to fix? Cause it works fine without vendoring. If this isn't ever going to be fixed, that's okay, I'm just trying to get a better understanding of what's going on that's causing the issue. |
I think it's just an update expected side effect of the combination of the I'm sorry I cannot advise you if or when it would be fixed. On Sat, 6 Aug 2016, 09:45 Sean Hagen notifications@github.com wrote:
|
On Aug 6, 2016 00:06, "Dave Cheney" notifications@github.com wrote:
Is it true though? Go compiler doesn't even know that it's a repository. |
I have tried to reproduce this issue with Go 1.6.2 and Go 1.7 (tip) but couldn't: https://github.com/kostya-sh/sandbox/tree/master/go/16622 |
@kostya-sh You have pkgA importing the internal package, and then calling pkga.A from main. The problem I ran into was if pkga is the main entry point, then the compilation fails. For example, if I change pkga.go to look like this:
And the internal repo is in vendor, then I get this error:
Dir structure for clarity
|
@seanhagen, so what you are saying is that I have updated https://github.com/kostya-sh/sandbox/tree/master/go/16622 |
@kostya-sh yeah, pretty much. |
/cc @rsc to make sure we want to do this. |
Thanks @kostya-sh for helping to clarify this and for the repo. To restate the problem, the issue is:
This follows from the definitions of internal and vendor. The definition of internal is intentionally about source directory location and not about comparing just import paths. If you have $GOPATH1/src/internal/foo then $GOPATH2/src/bar is not allowed to import "internal/foo" even though $GOPATH1/src/quux is. It is also intentional that internal's definition does not mention vendor, and vendor's definition does not mention internal. They are independent concepts. I understand that this case shows they interact in an unexpected way, but if we make an exception then they will interact in different unexpected ways. I don't think there's an obvious "everything is simple now" solution, so I would prefer to avoid introducing new special cases. I am not sure that internal is doing much work in the example. It might be best to rename the repo to something like base, core, common, lib. If this keeps coming up in other contexts we can revisit. But for now I'd like to be conservative and leave things alone. |
Please answer these questions before submitting your issue. Thanks!
go version
)?1.6.3
go env
)?If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
Created a repository named 'internal', to hold organization-level packages for a project of microservices and api clients ( "github.com/seanhagen/internal", example package "github.com/seanhagen/internal/tokens" )
Inside of a project using vendored dependencies ( via godep ), attempt to import a package from internal repo.
Binary to compile without issue.
However, when the vendor folder is removed,
go build
works fine. It seems that because the internal package is now located atvendor/github.com/seanhagen/internal/session
,go build
thinks that the files I'm trying to build are outside that tree/scope, and blocks the import of the internal package.It also works when just the
github.com/seanhagen/internal
folder is removed from the vendor folder.The text was updated successfully, but these errors were encountered: