首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >导入protos时找不到文件错误

导入protos时找不到文件错误
EN

Stack Overflow用户
提问于 2021-09-16 06:11:12
回答 1查看 134关注 0票数 0

我试图用来自Nighthawk项目的this proto创建Go gRPC客户端代码,我得到了这个错误:

代码语言:javascript
复制
user@computer:~/Code/nighthawk$ protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative api/client/output.proto 
envoy/config/core/v3/base.proto: File not found.
envoy/config/metrics/v3/stats.proto: File not found.
envoy/extensions/transport_sockets/tls/v3/cert.proto: File not found.
envoy/config/core/v3/extension.proto: File not found.
validate/validate.proto: File not found.
api/client/options.proto: Import "envoy/config/core/v3/base.proto" was not found or had errors.
api/client/options.proto: Import "envoy/config/metrics/v3/stats.proto" was not found or had errors.
api/client/options.proto: Import "envoy/extensions/transport_sockets/tls/v3/cert.proto" was not found or had errors.
api/client/options.proto: Import "envoy/config/core/v3/extension.proto" was not found or had errors.
api/client/options.proto: Import "validate/validate.proto" was not found or had errors.
api/client/options.proto:16:3: "envoy.config.core.v3.RequestMethod" is not defined.
api/client/options.proto:17:12: "envoy.config.core.v3.HeaderValueOption" is not defined.
api/client/options.proto:186:5: "envoy.config.core.v3.TypedExtensionConfig" is not defined.
api/client/options.proto:190:3: "envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext" is not defined.
api/client/options.proto:253:3: "envoy.config.core.v3.TransportSocket" is not defined.
api/client/options.proto:259:12: "envoy.config.metrics.v3.StatsSink" is not defined.
api/client/output.proto: Import "envoy/config/core/v3/base.proto" was not found or had errors.
api/client/output.proto: Import "api/client/options.proto" was not found or had errors.
api/client/output.proto:57:3: "nighthawk.client.CommandLineOptions" is not defined.
api/client/output.proto:59:3: "envoy.config.core.v3.BuildVersion" is not defined.

我看到这些protos是在特使的仓库here中定义的。

如何导入这些代码,以便生成客户端代码?

这个命令是什么?我错过了什么吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-09-22 17:37:07

通常,您不应该从其他人的.proto文件构建自己的.pb.go文件。如果在一个二进制文件中发现同一个proto包的多个定义,Go将会崩溃,因此理想情况下,发布的每个.proto文件都应该在一个中心位置提供.pb.go文件。如果nighthawk不是这样的话,你仍然可以自己构建它。您需要下载特使依赖项并通过-I参数引用它们。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69203166

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档