Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions repositories/go_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ repository.
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

def go_deps():
# go version for rules_go
GO_VERSION = "1.15.5"

def go_deps(version = GO_VERSION):
"""Pull in external Go packages needed by Go binaries in this repo.

Pull in all dependencies needed to build the Go binaries in this
Expand All @@ -31,7 +34,13 @@ def go_deps():
already.
"""
go_rules_dependencies()
go_register_toolchains()
sdk_kinds = ("_go_download_sdk", "_go_host_sdk", "_go_local_sdk", "_go_wrap_sdk")
existing_rules = native.existing_rules()
sdk_rules = [r for r in existing_rules.values() if r["kind"] in sdk_kinds]
if len(sdk_rules) > 0 or "go_sdk" in existing_rules:
go_register_toolchains()
else:
go_register_toolchains(version)
gazelle_dependencies()
excludes = native.existing_rules().keys()
if "com_github_google_go_containerregistry" not in excludes:
Expand Down