简体   繁体   English

为什么纵梁找不到包裹?

[英]Why stringer can't find the package?

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. 我有一个go生成器(stringer)我尝试运行,但它一直报告它找不到包导入,虽然包是肯定导入的。

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

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. 似乎是一个愚蠢的事情:4部分导入通常是子包,这些必须“ 安装 ”才能使用它们。 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: 确保使用最新的1.4.2并更新你的纵梁:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM