英文:
Unable to import a package
问题
我在添加了有效的导入路径后,仍然无法导入一个包。我可以通过使用别名来使其工作,但是当我尝试重新编译时,它再次失败并抱怨。
它首先抱怨一个未使用的包,然后是一个未定义的符号。这是 Travis-CI 构建的链接:https://travis-ci.org/Blackrush/gofus/builds/12145834 在我的计算机上使用 go1.1.2 linux/amd64 也出现了相同的问题。
为什么它无法编译,我该如何解决这个问题?
英文:
I'm having some trouble to import a package though I added a valid import path. I can make it works by using a alias but when I try a recompile, it fails again and complains again.
It first complains about an unused package and then about a undefined symbol. Here is the Travis-CI build : https://travis-ci.org/Blackrush/gofus/builds/12145834 the same is happening on my computer using go1.1.2 linux/amd64.
Why does it fail to compile and how can I fix this issue ?
答案1
得分: 2
在github.com/Blackrush/gofus/realm/network/frontend
包中的代码具有network
的包定义,但是在realm/config.go
中你将其引用为frontend.XXX
。
可以通过将引用更改为network.XXX
或在前端源代码中将package network
更改为package frontend
来解决此问题。
通常情况下,最好将包的名称与包含其源代码的目录名称相同。因此,目录foo
中的所有代码应具有package foo
的包声明。否则,可能会遇到类似这样的混淆错误。
英文:
The code in package github.com/Blackrush/gofus/realm/network/frontend
has the package definition network
, yet you are referencing it as frontend.XXX
in realm/config.go
.
This can be fixed by changing the references to network.XXX
or by changing package network
to package frontend
in the frontend source code.
In general, it is best to give a package the same name as the directory in which its source is contained. So all code in directory foo
should have a package declaration package foo
. Otherwise you may run into confusing errors like this.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论