如何在 Bazel 中使用 Google APIs with Go
How to use Google APIs with Go in Bazel
我目前正在尝试使用来自 Bazel 的 Go 中的 Google API(目前仅由于注释选项)。
有official repo for the proto API. There they redirect Go users to special go variant.
两者都只定义了一个存根 Bazel 包。因此 none 似乎可以直接使用。
因此,一种方法是分叉 the latter, introduce Packages to build go_proto_libraries
and hope that the directory structure appeases the go rules。
问题:
- 是否已经有另一个仓库,可以简单地使用?
如果没有:
- 后一个回购被标记为实验性的。更改的可能性有多大?
- 后面的 repo 是否保持同步?
- 应该使用后一个 repo 中的源还是使用 Bazel 从头开始构建的新源?
- 有更好的方法吗?
我问了 go 团队,答案是:
https://github.com/bazelbuild/rules_go/blob/master/proto/go_proto_library.bzl does not have a good solution for this case where the .proto is in a completely different location from the .pb.go files other than using a genrule to copy the .proto file from its source and then a go_proto_library to operate on it.
https://github.com/pubref/rules_protobuf/blob/master/go/rules.bzl has a go_proto_library that allows the .proto from one place and the .pb.go from another, but disclaimer: this code is not owned or maintained by Google.
As to the questions:
1) No
2) No idea
3) See 2
4) bazel always recommends generating from the source (in this case the .proto files)
5) Not yet
我目前正在尝试使用来自 Bazel 的 Go 中的 Google API(目前仅由于注释选项)。
有official repo for the proto API. There they redirect Go users to special go variant.
两者都只定义了一个存根 Bazel 包。因此 none 似乎可以直接使用。
因此,一种方法是分叉 the latter, introduce Packages to build go_proto_libraries
and hope that the directory structure appeases the go rules。
问题:
- 是否已经有另一个仓库,可以简单地使用?
如果没有:
- 后一个回购被标记为实验性的。更改的可能性有多大?
- 后面的 repo 是否保持同步?
- 应该使用后一个 repo 中的源还是使用 Bazel 从头开始构建的新源?
- 有更好的方法吗?
我问了 go 团队,答案是:
https://github.com/bazelbuild/rules_go/blob/master/proto/go_proto_library.bzl does not have a good solution for this case where the .proto is in a completely different location from the .pb.go files other than using a genrule to copy the .proto file from its source and then a go_proto_library to operate on it.
https://github.com/pubref/rules_protobuf/blob/master/go/rules.bzl has a go_proto_library that allows the .proto from one place and the .pb.go from another, but disclaimer: this code is not owned or maintained by Google.
As to the questions:
1) No
2) No idea
3) See 2
4) bazel always recommends generating from the source (in this case the .proto files)
5) Not yet