英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论