Skip to content

Commit

Permalink
docs: Discourage use go_sdk.host() in bzlmod.md (see #3967)
Browse files Browse the repository at this point in the history
  • Loading branch information
vorburger committed Jun 21, 2024
1 parent d3ecd76 commit 4dc7213
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/go/core/bzlmod.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ go_sdk.download(
go_sdk.host()
```

Nota bene: The use of `go_sdk.host()` [may break builds](https://github.com/enola-dev/enola/issues/713) whenever the host Go version is upgraded
(because many OS package managers, such as Debian/Ubuntu's `apt`, distribute Go into a directory which contains the version, such as `/usr/lib/go-1.22/`).
As package upgrades happen outside of Bazel's control, this will lead to non-reproducible builds. Due to this, use of `go_sdk.host()` is discouraged.

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).
As long as you specify the `version` of an SDK, it will be downloaded lazily, that is, only when it is actually needed during a particular build.
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.
Expand Down

0 comments on commit 4dc7213

Please sign in to comment.