Local import into a non-local package

I know that local imports should be avoided, but special circumstances are required in this case. It is a private repo and buildkack heroku does not work on stage, go get ./... using the URL-with absolute addresses due to the absence of the private key on the server.

Now I get this error local import ".." in non-local package .

All import paths have been changed to the local version, so what remains is the package identifying as β€œnon-local”? How to fix it?

+4
source share
3 answers

I fixed it. The problem was that the root package was in $GOPATH/src/<host>/<user>/<package> . As soon as I moved the package to ~/Git/<package> , the errors disappeared (thus, "made it local").

+4
source

The local package import path is the absolute path to the file system or one starting with. / Or ../. The path to import non-local packages is not the path to import a local package.

cmd / go / pkg.go

+1
source

peterSo is right. Considering the code in which this error message is generated, this will happen if the download package does not start with /./ or ../, but it imported the one that it did. In the event of your problem, there are several things that can cause this.

  • go calls a dependent package that is referenced by a non-local assembly path, which then loads the local path in turn.
  • you get the path to a non-local package that includes local import.

I think you should just fix the missing private key problem on the server, and not try to use the local path.

To properly debug, I would need to know which packages you received and what their transitive dependencies are.

Last, why do you use go to set the path locally (i.e. go get ./... )? go install or go build, usually you want in this case.

0
source

All Articles