How to use Google APIs with Go in Bazel

huangapple go评论92阅读模式
英文:

How to use Google APIs with Go in Bazel

问题

我目前正在尝试使用Go从Bazel消费Google APIs(目前仅限于注释选项)。

有一个官方仓库用于proto API。在那里,他们将Go用户重定向到特殊的Go变体

两者都只定义了一个存根Bazel包。因此,似乎都不能直接使用。

因此,一种方法是fork 后者,引入Packages来构建go_proto_libraries,并希望目录结构符合go rules
问题:

  1. 是否已经有另一个可以简单使用的仓库?

如果没有:

  1. 后者的仓库被标记为实验性的。更改的可能性有多大?
  2. 后者的仓库是否保持同步?
  3. 应该使用后者仓库中的源代码还是使用Bazel从头开始构建新的源代码?
  4. 是否有更好的方法来完成这个任务?
英文:

I am currently trying to consume Google APIs (for now only due to the annotation options) in Go from Bazel.

There is the official repo for the proto API. There they redirect Go users to special go variant.

Both have only a stub Bazel package defined. Thus none seems to be directly usable.

So one way to do this would be to fork the latter, introduce Packages to build go_proto_libraries and hope that the directory structure appeases the go rules.
Questions:

  1. Is there already another repository, which can be used simply?

If not:

  1. The latter repo is marked as experimental. How likely are changes?
  2. Is the latter repo kept in sync?
  3. Should the sources in the latter repo be used or new ones built with Bazel from scratch?
  4. Is there a better way of doing this?

答案1

得分: 2

我问了Go团队,答案是:

至于问题:

  1. 不是

  2. 不知道

  3. 参见2

  4. bazel始终建议从源代码生成(在这种情况下是.proto文件)

  5. 还没有

英文:

I asked the go team and the answer was:

> 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

huangapple
  • 本文由 发表于 2017年5月16日 19:51:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/44000686.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定