What causes an error message like "internal error: failed to find embedded files of…" in go?

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

What causes an error message like "internal error: failed to find embedded files of..." in go?

问题

我已经在我的分支上工作了几天。与此同时,master分支已经发生了变化,所以我执行了git rebase master命令。

输出显示一些文件中存在冲突:

正在合并 vendor/modules.txt
冲突(内容):合并冲突在 vendor/modules.txt 中
正在合并 go.sum
冲突(内容):合并冲突在 go.sum 中
正在合并 go.mod
冲突(内容):合并冲突在 go.mod 中
错误:无法应用 1bd673ea... 更新 vendor 文件夹
请手动解决所有冲突,并使用以下命令将其标记为已解决:
"git add/rm <冲突文件>", 然后运行 "git rebase --continue"。
你也可以跳过此提交:运行 "git rebase --skip"。
要中止并返回到 "git rebase" 之前的状态,请运行 "git rebase --abort"。
无法应用 1bd673ea... 更新 vendor 文件夹

在解决冲突后,我执行了go mod tidy,然后执行了go mod vendor。结果出现了一个奇怪的消息:

内部错误:无法找到 github.com/grpc-ecosystem/grpc-gateway/v2/runtime 的嵌入文件://go:build 注释缺少 // +build 注释

这是什么意思,我该如何避免这个问题?

英文:

I have been working on my branch for a couple of days. Meanwhile the master branch has evolved, so I do git rebase master.

The output shows CONFLICTs in some files:

Auto-merging vendor/modules.txt
CONFLICT (content): Merge conflict in vendor/modules.txt
Auto-merging go.sum
CONFLICT (content): Merge conflict in go.sum
Auto-merging go.mod
CONFLICT (content): Merge conflict in go.mod
error: could not apply 1bd673ea... update vendor folder
Resolve all conflicts manually, mark them as resolved with
update vendor folder
&quot;git add/rm &lt;conflicted_files&gt;&quot;, then run &quot;git rebase --continue&quot;.
You can instead skip this commit: run &quot;git rebase --skip&quot;.
To abort and get back to the state before &quot;git rebase&quot;, run &quot;git rebase --abort&quot;.
Could not apply 1bd673ea... update vendor folder

After fixing the conflicts, I do go mod tidy and then go mod vendor. The result is a strange message:

internal error: failed to find embedded files of github.com/grpc-ecosystem/grpc-gateway/v2/runtime: //go:build comment without // +build comment

What does this mean and how can I avoid it?

答案1

得分: 3

从最终的错误信息//go:build comment without // +build comment来看,似乎有一个工具期望同时使用新的//go:build和旧的// +build构建约束风格。我猜测这是因为你的go.mod文件中指定了你要支持比1.18版本更旧的Go版本(在1.18版本中// +build已经过时),但是这个grpc-gateway包是为Go 1.18编写的,只包含了//go:build风格的约束。

查看相关文件的源代码,看起来它只有一个//go:build注释,但是go.mod文件指定它应该支持Go 1.17。所以看起来这个包是有问题的...实际上,似乎有一个未解决的问题与此相关。所以你可能需要等待他们修复,使用一个可用的旧版本,或者在你自己的go.mod文件中使用replace来使用一个分支。

我认为在几天前的v2.10.2版本发布时出现了问题,当时添加了那个带有//go:build行但没有// +build行的fuzz文件。

**更新:**看起来这个问题已经在v2.10.3中修复了。

英文:

From the final error message //go:build comment without // +build comment, it looks one of the tools is expecting both the new //go:build and the old // +build build constraint styles. My guess is this is because your go.mod says you want to support a version of Go older than 1.18 (when // +build became obsolete) but this grpc-gateway package is written for Go 1.18 and only includes a //go:build style constraint.

Looking at the source of the file in question, it looks like it does only have a //go:build comment, but the go.mod says it should support Go 1.17. So it seems like that package is broken... in fact, looks like there's an open issue related to that. So you'll probably have to wait for them to fix it, use an older version that works, or use a replace in your own go.mod to use a fork.

I think this was broken a few days ago with the release of v2.10.2, when that fuzz file was added with the //go:build line and no // +build one.

Update: looks like this has been fixed in v2.10.3.

huangapple
  • 本文由 发表于 2022年6月1日 08:35:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/72455352.html
匿名

发表评论

匿名网友

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

确定