From 7bc33f83173ca3d5b9581196bca9256a05bb3051 Mon Sep 17 00:00:00 2001 From: Stefan Penner Date: Mon, 6 May 2024 11:11:44 -0600 Subject: [PATCH] Add docs for Go.Work Support Docs for https://github.com/bazelbuild/bazel-gazelle/pull/1731 --- docs/go/core/bzlmod.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/go/core/bzlmod.md b/docs/go/core/bzlmod.md index 55e84634b..adb4e4e30 100644 --- a/docs/go/core/bzlmod.md +++ b/docs/go/core/bzlmod.md @@ -160,6 +160,24 @@ go_deps.module( ) ``` +#### Specifying Workspaces + +`go.work` is supported by the go_deps module extension provided by Gazelle. + +```starlark +go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps") +go_deps.from_file(go_work = "//:go.work") + +# All *direct* Go dependencies of all `go.mod` files referenced by the `go.work` file have to be listed explicitly. +use_repo( + go_deps, + "com_github_gogo_protobuf", + "com_github_golang_mock", + "com_github_golang_protobuf", + "org_golang_x_net", +) +``` + #### Depending on tools If you need to depend on Go modules that are only used as tools, you can use the [`tools.go` technique](https://github.com/golang/go/issues/25922#issuecomment-1038394599):