如果您懒惰,可以快速添加新的 Bazel github 外部存储库吗?
Quick way to add new Bazel github external repository if you're lazy?
我正在使用 Bazel 和 gazelle 来管理我的 Go 项目的 BUILD.bazel 文件。
我希望跨语言保持一致并避免使用 Go 的特定供应商工具。
我禁用了瞪羚的供应商。它为那些存储库生成 BUILD 条目非常好,但我坚持自己为 git_repository
或 http_archive
编写 WORKSPACE 咒语。如果我正在使用的项目有很多外部依赖项,这当然会变得乏味。
有没有更方便的方法呢? gazelle 是否支持更新 WORKSPACE 文件?
谢谢。
回答我自己的问题:Bazel 团队似乎想为 Gazelle 添加对此的支持,但在此之前我们可以使用 wtool:
$ go get -u github.com/bazelbuild/rules_go/go/tools/wtool
$ github.com/gordonklaus/portaudio
This will update the WORKSPACE file accordingly. The command doesn't even have to be run from the repository root - which is nice.
这是 运行 以上命令后我的 WORKSPACE 的差异:
$ git diff WORKSPACE
diff --git a/WORKSPACE b/WORKSPACE
index 3b15779..c170b60 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -50,3 +50,8 @@ go_repository(
importpath = "google.golang.org/api",
)
+go_repository(
+ name = "com_github_gordonklaus_portaudio",
+ commit = "e66c30a9c4ca11f93538cf8c004831bfb76f3838",
+ importpath = "github.com/gordonklaus/portaudio",
+)
我正在使用 Bazel 和 gazelle 来管理我的 Go 项目的 BUILD.bazel 文件。
我希望跨语言保持一致并避免使用 Go 的特定供应商工具。
我禁用了瞪羚的供应商。它为那些存储库生成 BUILD 条目非常好,但我坚持自己为 git_repository
或 http_archive
编写 WORKSPACE 咒语。如果我正在使用的项目有很多外部依赖项,这当然会变得乏味。
有没有更方便的方法呢? gazelle 是否支持更新 WORKSPACE 文件?
谢谢。
回答我自己的问题:Bazel 团队似乎想为 Gazelle 添加对此的支持,但在此之前我们可以使用 wtool:
$ go get -u github.com/bazelbuild/rules_go/go/tools/wtool
$ github.com/gordonklaus/portaudio
This will update the WORKSPACE file accordingly. The command doesn't even have to be run from the repository root - which is nice.
这是 运行 以上命令后我的 WORKSPACE 的差异:
$ git diff WORKSPACE
diff --git a/WORKSPACE b/WORKSPACE
index 3b15779..c170b60 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -50,3 +50,8 @@ go_repository(
importpath = "google.golang.org/api",
)
+go_repository(
+ name = "com_github_gordonklaus_portaudio",
+ commit = "e66c30a9c4ca11f93538cf8c004831bfb76f3838",
+ importpath = "github.com/gordonklaus/portaudio",
+)