无法识别的导入路径(导入路径不是以主机名开头)
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.
我已经按照安装说明(如我已安装到用户目录中)以适应具有多个版本的 走。 p>
当我从go项目的src目录中获得代码时,我得到了上面已经提到的错误消息类型 p>
无法识别的导入路径(导入路径不是以主机名开头) p> blockquote>
请您解释一下,为什么要查找主机名以及如何查找主机名 p>
顺便说一句,我最初在设置遵循特定的项目和哈希值,仍然接受该答案。 p> div>
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.