Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unrecognized import path (import path does not begin with hostname)

Tags:

go

I've installed go as per the custom installation clause of the installation instructions, as I have installed to a user directory, in order to accommodate having multiple versions of go.

When I go get . from my go project's src directory, I get the error message type already mentioned above ―

unrecognized import path (import path does not begin with hostname)

Can you please explain, why does go look for a hostname and how that should possibly be avoided in a typical project?

As an aside, the problem was originally encountered by me in setting up the following specific project and hash, which the accepted answer still refers to.

like image 512
matanster Avatar asked Nov 08 '17 18:11

matanster


1 Answers

go get downloads dependencies and packages by assuming that the import path (in the import statements in source code) identifies a URL where the package can be downloaded, e.g. github.com/habeanf/yap. It works so long as developers use imports correctly; unfortunately, the developer of the yap project did not.

Where they import yap/app, they should be importing github.com/habeanf/yap/app, etc. The only fix would be to clone the GitHub repo into $GOPATH/src/yap manually and then try to build it. You might want to open a GitHub issue on that project and request that they fix the import paths so it can be built like a normal Go project.

like image 98
Adrian Avatar answered Oct 18 '22 23:10

Adrian