为什么stringer找不到该包?

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

Why stringer can't find the package?

问题

你好!以下是翻译好的内容:

有任何想法如何修复下面的错误吗?我有一个 Go 生成器(stringer),我尝试运行它,但它一直报告说找不到一个已经导入的包。

stringer: 检查包: main.go:13:3: 无法导入 example.io/api/util(找不到导入:example.io/api/util)
main.go:33: 运行 "stringer": 退出状态 1
英文:

Any idea how can I fix the error below? I have a go generator (stringer) which I try to run but it keeps reporting that it can't find a package import although the package is definitely imported.

stringer: checking package: main.go:13:3: could not import example.io/api/util (can't find import: example.io/api/util)
main.go:33: running "stringer": exit status 1

答案1

得分: 8

这个帖子中:

> 看起来是一个愚蠢的事情:4部分导入通常是子包,这些子包必须在使用之前“安装”。我在命令行上运行了以下命令来解决我的问题:

所以首先尝试:

go install <yourpackage>

然后看看 go generate 是否能正常工作。

确保使用最新的 go 1.4.2,并更新您的 stringer:

go get -u golang.org/x/tools/cmd/stringer
英文:

From this thread:

> Seems to be a silly thing: 4 part import are usually subpackages and these must be "installed" before you can use them. I ran the following on the command line to resolve my problem:

So try first:

go install <yourpackage>

Ad see if go generate works after that.

Make sure to use the latest go 1.4.2 and to update your stringer as well:

go get -u golang.org/x/tools/cmd/stringer

huangapple
  • 本文由 发表于 2015年3月10日 14:18:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/28957282.html
匿名

发表评论

匿名网友

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

确定