-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: internal package is importable to the packages which is not rooted in the same subtree. #12217
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
Comments
I can believe there is a bug here. The last one was #11331 fixed by https://go-review.googlesource.com/#/c/12450/, but that was before Go 1.5 and the report says the problem happened with Go 1.5. However, I cannot reproduce this. In addition to what's in the initial report, I need:
I have tried to guess these, in particular by running various exhaustive searches over possible ways the imports could be arranged, and I cannot find any cases where otherpkg would be allowed to import mypkg/internal/foo. If you still have the information available, can you give us more detail? Thanks. |
hi @rsc , For the sake of a conveniency debuging, I pushed the code into my experiments repository on github.
I ran the example again on both Mac and ubuntu,the problem can still be reproduceable. the steps are like below:
On linux ( 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux) go 1.5.2,I got the same result after executing the same steps above. |
But I found go build command is correct to detect the internal not allowed error.
go run can not detect the error:
|
CL https://golang.org/cl/18645 mentions this issue. |
the project layout is below: (GOPATH=/home/bigwhite/gotestinternal)
I am trying to test the internal package in go 1.5 final release. according to the internal design doc, if we import internal/foo in mypkg/main.go or mypkg/pkg1/main.go, it is ok. but if we import mypkg/internal/foo in otherpkg/main.go, it should be invalid.
But the test result is not as the above:
we build otherpkg/main.go in otherpkg directory, but no error occurs. It is not the result expected.
but go list -json tell us we has a not-allowed use of internal package:
I'm not sure whether it is a problem of go1.5.
The text was updated successfully, but these errors were encountered: