Skip to content

Commit

Permalink
Add docs for Go.Work Support
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanpenner authored May 6, 2024
1 parent fd77fd0 commit 6d635b2
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions docs/go/core/bzlmod.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ If there is no `go.mod` file in the same directory as your top-level BUILD file,

Then, use `bazel run //:gazelle` to (re-)generate BUILD files.


## External dependencies

External Go dependencies are managed by the `go_deps` module extension provided by Gazelle.
Expand Down Expand Up @@ -160,6 +161,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):
Expand Down

0 comments on commit 6d635b2

Please sign in to comment.