Skip to content

Commit

Permalink
Use a unique name for the Go SDK that we use for ourselves
Browse files Browse the repository at this point in the history
I'm not sure if this is the best way to solve this problem, but
there are two cases where we want to use this repo:

1/ We're developing the repo itself. We should be responsible for
   registering the Go toolchain.

2/ We're being used transitively by another module (eg.
   `contrib_rules_jvm`. We should _not_ be responsible for
   registering the Go toolchain

Now, in the ideal world, we'd declare the Go SDK as a dev
dependency, and everything would be fine. However, we can't do
this because there's no way to gate the call to `register_toolchain`
on us being the root module or not.

The workaround? Attempt to use a unique name for the Go SDK that
we need and hope that this works as we think it does.
  • Loading branch information
shs96c committed Nov 11, 2022
1 parent 60abca8 commit 9ec65a4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions gazelle/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ bazel_dep(name = "rules_go", repo_name = "io_bazel_rules_go", version = "0.35.0"
go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")

go_sdk.download(
name = "go_sdk",
name = "bazel_skylib_gazelle_plugin_go_sdk",
version = "1.18",
)

use_repo(go_sdk, "go_sdk")
use_repo(go_sdk, "bazel_skylib_gazelle_plugin_go_sdk")

register_toolchains("@go_sdk//:all")
register_toolchains("@bazel_skylib_gazelle_plugin_go_sdk//:all")

go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps")

Expand Down

0 comments on commit 9ec65a4

Please sign in to comment.