【问题标题】:Using GoGo Protobuf .proto sources in my own Protobufs with Bazel在我自己的带有 Bazel 的 Protobufs 中使用 GoGo Protobuf .proto 源
【发布时间】:2020-12-17 04:17:53
【问题描述】:

我正在尝试在我的 Protobuf 定义中使用(导入)GoGo Protobuf,特别是 gogoproto/gogo.proto

目前我将它定义为http_archive,我不确定这是否是由Gazelle 完成的,但是在查询依赖项时,我可以通过某种方式看到可用的目标:

$ bazel query @com_github_gogo_protobuf//gogoproto:all
@com_github_gogo_protobuf//gogoproto:go_default_library_protos
@com_github_gogo_protobuf//gogoproto:go_default_library
@com_github_gogo_protobuf//gogoproto:gogoproto
Loading: 0 packages loaded

但是,当我使用--output=build 进行更深入的检查时,我只看到go_library 目标。为了让我在自己的 Protobuf 源中使用 gogo.proto 源作为导入,我需要 proto_library 目标可用。

我尝试自己定义它(在我自己的 proto_library 旁边和作为覆盖 BUILD 文件),但无济于事(由于各种错误和冲突)。

我猜最惯用的方法是让 Bazel 和/或 Gazelle 为 GoGo Protobuf 生成 proto_library 目标,但我还没有弄清楚如何做到这一点。

我将非常感谢有关此问题的任何见解和/或指导。

谢谢。

【问题讨论】:

    标签: protocol-buffers bazel


    【解决方案1】:

    我认为您需要在 proto 文件中指明完整路径,如下所示:

    import "github.com/gogo/protobuf/gogoproto/gogo.proto";
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-23
      • 1970-01-01
      • 1970-01-01
      • 2011-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多