英文:
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 CONFLICT
s 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
"git add/rm <conflicted_files>", then run "git rebase --continue".
You can instead skip this commit: run "git rebase --skip".
To abort and get back to the state before "git rebase", run "git rebase --abort".
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论