Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Steven E. Harris <[email protected]>
  • Loading branch information
fmeum and seh authored Apr 6, 2023
1 parent 483215c commit 1724380
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions docs/go/core/bzlmod.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Go with Bzlmod

This document describes how to use rules_go and Gazelle with Bazel's new external dependency subsystem [Bzlmod](https://bazel.build/external/overview#bzlmod), which is meant to replace `WORKSPACE` files eventually.
Usages of rules_go and Gazelle in `BUILD` files are not affected by this, refer to the existing documentation on rules and configuration options for them.
Usages of rules_go and Gazelle in `BUILD` files are not affected by this; refer to the existing documentation on rules and configuration options for them.

## Setup

Expand Down Expand Up @@ -33,7 +33,7 @@ go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
# Download an SDK for the host OS & architecture.
go_sdk.download(version = "1.20.3")

# Download an SDK for a fixed OS/architecture, e.g. for remote execution.
# Alternately, download an SDK for a fixed OS/architecture, e.g. for remote execution.
go_sdk.download(
version = "1.20.3",
goarch = "amd64",
Expand All @@ -44,7 +44,7 @@ go_sdk.download(
go_sdk.host()
```

Multiple Go SDKs can be registered and selected on a per-target basis using [`go_cross_binary`](rules.md#go_cross_binary).
You can register multiple Go SDKs and select which one to use on a per-target basis using [`go_cross_binary`](rules.md#go_cross_binary).
The usual rules of [toolchain resolution](https://bazel.build/extending/toolchains#toolchain-resolution) apply, with SDKs registered in the root module taking precedence over those registered in dependencies.

### Using a Go SDK
Expand Down Expand Up @@ -95,7 +95,7 @@ For every major version of a Go module, there will only ever be a single version
### Specifying external dependencies

Even though this is not a strict requirement, for interoperability with Go tooling that isn't Bazel-aware, it is recommended to manage Go dependencies via `go.mod`.
The `go_deps` extension can directly parse this file, so external tooling such as `gazelle update-repos` is no longer needed.
The `go_deps` extension parses this file directly, so external tooling such as `gazelle update-repos` is no longer needed.

Register the `go.mod` file with the `go_deps` extension as follows:

Expand All @@ -116,7 +116,7 @@ use_repo(
There is [ongoing work](https://github.com/bazelbuild/bazel/issues/17908) targeted for Bazel 6.2.0 to automate the generation of the `use_repo` statement.

Alternatively, you can specify a module extension tag to add an individual dependency.
This can for example be useful for dependencies of generated code that `go mod tidy` would remove (there is [ongoing work](https://github.com/bazelbuild/bazel-gazelle/pull/1495) to provide a Bazel-aware version of `tidy`).
This can be useful for dependencies of generated code that `go mod tidy` would remove. (There is [ongoing work](https://github.com/bazelbuild/bazel-gazelle/pull/1495) to provide a Bazel-aware version of `tidy`.)

```starlark
go_deps.module(
Expand Down

0 comments on commit 1724380

Please sign in to comment.