1# Load the http ruleset and expose the http_archive rule 2load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 3 4# Download rules_go ruleset. 5# Bazel makes a https call and downloads the zip file, and then 6# checks the sha. 7http_archive( 8 name = "io_bazel_rules_go", 9 sha256 = "6b65cb7917b4d1709f9410ffe00ecf3e160edf674b78c54a894471320862184f", 10 urls = [ 11 "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip", 12 "https://github.com/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip", 13 ], 14) 15 16# Download the bazel_gazelle ruleset. 17http_archive( 18 name = "bazel_gazelle", 19 sha256 = "727f3e4edd96ea20c29e8c2ca9e8d2af724d8c7778e7923a854b2c80952bc405", 20 urls = [ 21 "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.30.0/bazel-gazelle-v0.30.0.tar.gz", 22 "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.30.0/bazel-gazelle-v0.30.0.tar.gz", 23 ], 24) 25 26# Load rules_go ruleset and expose the toolchain and dep rules. 27load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") 28 29# the line below instructs gazelle to save the go dependency definitions 30# in the deps.bzl file. Located under '//'. 31load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") 32 33############################################################ 34# Define your own dependencies here using go_repository. 35# Else, dependencies declared by rules_go/gazelle will be used. 36# The first declaration of an external repository "wins". 37############################################################ 38 39# The following line defines the symbol go_dependencies from the deps.bzl file. 40# Having the deps in that file, helps the WORKSPACE file stay less 41# cluttered. The library symbol go_dependencies is then added to 42# the envionment. The line below calls that function. 43load("//:deps.bzl", "go_dependencies") 44 45# The next comment line includes a macro that gazelle reads. 46# This macro tells Gazelle to look for repository rules in a macro in a .bzl file, 47# and allows Gazelle to find the correct file to maintain the Go dependencies. 48# Then the line after the comment calls go_dependencies(), and that funcation 49# contains calls to various go_repository rules. 50 51# gazelle:repository_macro deps.bzl%go_dependencies 52go_dependencies() 53 54# go_rules_dependencies is a function that registers external dependencies 55# needed by the Go rules. 56# https://github.com/bazelbuild/rules_go/blob/master/go/dependencies.rst#go_rules_dependencies 57go_rules_dependencies() 58 59# The next rule installs the Go toolchains. The Go version is specified 60# using the version parameter. This rule will download the Go SDK. 61# https://github.com/bazelbuild/rules_go/blob/master/go/toolchains.rst#go_register_toolchains 62go_register_toolchains(version = "1.20.2") 63 64# The following call configured the gazelle dependencies, Go environment and Go SDK. 65gazelle_dependencies() 66