无法识别的导入路径(导入路径不是以主机名开头) [英] unrecognized import path (import path does not begin with hostname)

查看:44
本文介绍了无法识别的导入路径(导入路径不是以主机名开头)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经按照

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.

当我从go项目的src目录中获取代码时,我得到了上面已经提到的错误消息类型

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.

推荐答案

go get 通过假设导入路径(在源代码的 import 语句中)下载依赖项和程序包代码)标识可以在其中下载软件包的URL,例如github.com/habeanf/yap.只要开发人员正确使用导入,它就可以工作.不幸的是,yap项目的开发人员没有.

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.

他们在导入 yap/app 的地方,应该在导入 github.com/habeanf/yap/app 等,唯一的解决方法是克隆GitHub存储库手动插入 $ GOPATH/src/yap 中,然后尝试构建它.您可能要在该项目上打开GitHub问题,并要求他们修复导入路径,以便可以像普通的Go项目一样构建它.

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.

这篇关于无法识别的导入路径(导入路径不是以主机名开头)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆