登录
首页 >  Golang >  Go问答

造成 go 出现“内部错误:无法找到...的嵌入文件”错误消息的原因是什么?

来源:stackoverflow

时间:2024-02-08 15:54:21 200浏览 收藏

IT行业相对于一般传统行业,发展更新速度更快,一旦停止了学习,很快就会被行业所淘汰。所以我们需要踏踏实实的不断学习,精进自己的技术,尤其是初学者。今天golang学习网给大家整理了《造成 go 出现“内部错误:无法找到...的嵌入文件”错误消息的原因是什么?》,聊聊,我们一起来看看吧!

问题内容

我已经在我的分支上工作了几天。与此同时,master 分支已经发展,所以我做了 git rebase master

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

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 ", 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

修复冲突后,我执行 go mod tidy ,然后执行 go modvendor 。结果是一条奇怪的消息:

内部错误:找不到 github.com/grpc-ecosystem/grpc-gateway/v2/runtime 的嵌入文件://go:build comment without // +build comment

这是什么意思以及如何避免它?


正确答案


从最终的错误消息 //go:build comment without // +build comment 来看,其中一个工具似乎需要新的 //go:build 和旧的 // +build 构建约束样式。我的猜测是,这是因为你的 go.mod 说你想支持 1.18 之前的 Go 版本(当 // +build 过时时),但是这个 grpc-gateway 包是为 Go 1.18 编写的,只包含 // go:build 样式约束。

查看 file in question 的来源,看起来它只有 //go:build 注释,但 go.mod 说它应该支持 Go 1.17。所以看起来那个包坏了……事实上,看起来有一个与此相关的 open issue。因此,您可能必须等待他们修复它,使用可以工作的旧版本,或者在您自己的 go.mod 中使用 replace 来使用 fork。

我认为几天前随着 v2.10.2 的发布,这个问题被打破了,当时该模糊文件是通过 //go:build 行添加的,而没有 // +build 行。

更新:看起来此问题已在 v2.10.3 中修复。

终于介绍完啦!小伙伴们,这篇关于《造成 go 出现“内部错误:无法找到...的嵌入文件”错误消息的原因是什么?》的介绍应该让你收获多多了吧!欢迎大家收藏或分享给更多需要学习的朋友吧~golang学习网公众号也会发布Golang相关知识,快来关注吧!

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>