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: "go get -u" handles internal imports incorrectly #11307

Closed
cskr opened this issue Jun 20, 2015 · 5 comments
Closed

cmd/go: "go get -u" handles internal imports incorrectly #11307

cskr opened this issue Jun 20, 2015 · 5 comments
Milestone

Comments

@cskr
Copy link

cskr commented Jun 20, 2015

Go version:

go version devel +79d4d6e Sat Jun 20 00:52:38 2015 +0000 linux/amd64

go get github.com/kisielk/errcheck completes successfully, but go get -u github.com/kisielk/errcheck fails with the following error.

package github.com/kisielk/errcheck
    imports github.com/kisielk/errcheck/internal/errcheck
    imports github.com/kisielk/errcheck/internal/errcheck
    imports github.com/kisielk/errcheck/internal/errcheck: use of internal package not allowed
@dmitshur
Copy link
Contributor

That is strange. I'm not seeing anything wrong with the current code of github.com/kisielk/errcheck/....

github.com/kisielk/errcheck imports github.com/kisielk/errcheck/internal/errcheck, and that's it. That should be valid.

@mikioh mikioh changed the title "go get -u" handles internal imports incorrectly cmd/go: "go get -u" handles internal imports incorrectly Jun 23, 2015
@dsymonds
Copy link
Contributor

Possibly related or the same as #11055.

@jscrockett01
Copy link

I've spent a while chasing this down, and although I didn't have time to resolve it I can pass along some leads:

At its heart the problem is that the disallowInternal() logic in cmd/go/pkg.go is sometimes using srcDir == os.Getwd() during validation of internal imports, instead of using the Package.Dir of the parent package.

This happens because 'go get -u' loads the imports through func loadPackage() whereas ordinarily imports are loaded through func loadImport() in the same file. At the end of loadPackage() the call to loadImport() is made using cwd (== os.Getwd()) as the srcDir. You can verify this by running 'go get -u' from the target directory where you want to install, and it doesn't complain.

@jscrockett01
Copy link

Regarding the inaccurate import stacks, there is a missing stk.pop() in func download() of src/cmd/go/get.go, between lines 233-234 (go1.5beta1) corresponding to the stk.push() at line 192. Also, the stk.push/pop pair at lines 225-227 are extraneous.

@gopherbot
Copy link

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

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

6 participants