无法导入一个包。

huangapple go评论87阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2013年10月5日 03:04:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/19188887.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定