Go rules for Bazel
WORKSPACE
codeload("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
sha256 = "80a98277ad1311dacd837f9b16db62887702e9f1d1c4c9f796d0121a46c8e184",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.46.0/rules_go-v0.46.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.46.0/rules_go-v0.46.0.zip",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.22.0")
GOARM
architecture levels via platform constraints by @LINKIWI in https://github.com/bazelbuild/rules_go/pull/3837
Full Changelog: https://github.com/bazelbuild/rules_go/compare/v0.45.1...v0.46.0
WORKSPACE
codeload("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
sha256 = "6734a719993b1ba4ebe9806e853864395a8d3968ad27f9dd759c196b3eb3abe8",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.45.1/rules_go-v0.45.1.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.45.1/rules_go-v0.45.1.zip",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.21.6")
layering_check
feature in CGo tests by @fmeum in https://github.com/bazelbuild/rules_go/pull/3829
.go
file filtering for nogo by @fmeum in https://github.com/bazelbuild/rules_go/pull/3832
Full Changelog: https://github.com/bazelbuild/rules_go/compare/v0.45.0...v0.45.1
WORKSPACE
codeload("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
sha256 = "de7974538c31f76658e0d333086c69efdf6679dbc6a466ac29e65434bf47076d",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.45.0/rules_go-v0.45.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.45.0/rules_go-v0.45.0.zip",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.21.6")
//proto:go_grpc
by @fmeum in https://github.com/bazelbuild/rules_go/pull/3818
COVERAGE_DIR
env variable by @fmeum in https://github.com/bazelbuild/rules_go/pull/3820
Full Changelog: https://github.com/bazelbuild/rules_go/compare/v0.44.2...v0.45.0
WORKSPACE
codeload("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
sha256 = "7c76d6236b28ff695aa28cf35f95de317a9472fd1fb14ac797c9bf684f09b37c",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.44.2/rules_go-v0.44.2.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.44.2/rules_go-v0.44.2.zip",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.21.5")
Full Changelog: https://github.com/bazelbuild/rules_go/compare/v0.44.1...v0.44.2
This patch release is to include https://github.com/bazelbuild/rules_go/commit/43c40a9a596fcf37a5b7b0ae5f32832277393587 which reverts a change to forcefully upgrade genproto transitively, which is causing linker failures since google.golang.org/genproto/googleapis/rpc
was separated from google.golang.org/genproto
WORKSPACE
codeload("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
sha256 = "b6828eb2d03bb5ef76f2077f8670b211fe792e77ddb83450ea9f887df04db9c7",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.44.1/rules_go-v0.44.1.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.44.1/rules_go-v0.44.1.zip",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.21.5")
@rules_go//go
file path end with /bin/go
by @fmeum in https://github.com/bazelbuild/rules_go/pull/3791
runfiles.Env
by @fmeum in https://github.com/bazelbuild/rules_go/pull/3778
--nolegacy_external_runfiles
by @fmeum in https://github.com/bazelbuild/rules_go/pull/3795
Full Changelog: https://github.com/bazelbuild/rules_go/compare/v0.44.0...v0.44.1
panic()
when they timeoutThis means there is a running goroutine (which will fail goleak detection)
[Goroutine 26 in state chan receive, with github.com/bazelbuild/rules_go/go/tools/bzltestutil.RegisterTimeoutHandler.func1 on top of the
This also means there may be some different behavior when calling SIGTERM
directly from within a test.
For more information see: https://github.com/bazelbuild/rules_go/pull/3749
nogo
This can be added in your MODULE.bazel
file:
go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(
name = "go_sdk",
...
)
go_sdk.nogo(
nogo = "//:default_nogo",
)
For more information see https://github.com/bazelbuild/rules_go/pull/3782
WORKSPACE
codeload("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
sha256 = "c8035e8ae248b56040a65ad3f0b7434712e2037e5dfdcebfe97576e620422709",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.44.0/rules_go-v0.44.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.44.0/rules_go-v0.44.0.zip",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.21.5")
tools.go
trick to make go.mod
work with go mod tidy
by @fmeum in https://github.com/bazelbuild/rules_go/pull/3775
aux_files
relative paths for gomock source mocks (fix #3752) by @ikavalio in https://github.com/bazelbuild/rules_go/pull/3753
nogo
by @fmeum in https://github.com/bazelbuild/rules_go/pull/3782
Full Changelog: https://github.com/bazelbuild/rules_go/compare/v0.43.0...v0.44.0
x/tools
upgradeThis change includes a breaking upgrade to golang.org/x/tools
Please make sure to upgrade x/tools
to version v0.15.0
to ensure compatibility with rules_go's NoGo.
If you need to use an older version of x/tools
(v0.13.0
or earlier), apply the following patch to rules_go
:
x-tools.patch
0.42.0
release by @tyler-french in https://github.com/bazelbuild/rules_go/pull/3716
go.env
in //go
runfiles by @fmeum in https://github.com/bazelbuild/rules_go/pull/3722
bazel_features
to v1.1.1 by @fmeum in https://github.com/bazelbuild/rules_go/pull/3747
xtest
packages in Go Packages Driver by @JamyDev in https://github.com/bazelbuild/rules_go/pull/3750
Full Changelog: https://github.com/bazelbuild/rules_go/compare/v0.42.0...v0.43.0
Added patches
to go_download_sdk
:
Patches can now be applied to the standard library using go_download_sdk
(and go_sdk.download
for Bzlmod).
Example:
go_download_sdk(
name = "go_sdk",
sdks = {
"linux_amd64": (
"go{}.linux-amd64.mirror6598503.tar.gz".format(go_version),
"3f5c50e592d8845d30eebd08ddb9c670fd2d909e032b6c2b83ecf97afb34660c",
),
"darwin_arm64": (
"go{}.darwin-arm64.mirror6598503.tar.gz".format(go_version),
"fbe78beee7861da09de9319498a1521bc41a8b79d3ead2218ce307b9fa5503e5",
),
},
patches = [
"//patches:golang_osx_dns_workaround.patch",
],
urls = ["https://dl.google.com/go/{}"],
version = go_version,
)
Other changes included:
go_sdk
module extension as {os,arch}_dependent
by @fmeum (#3703)go_local_sdk
by @fmeum (#3696)exec_tools
to tools
on genrule
by @fmeum (#3638)//go/config:linkmode
for go_test
by @fmeum (#3629)//go/config:linkmode
flag value not being effective by @fmeum (#3627)Full Changelog: https://github.com/bazelbuild/rules_go/compare/v0.41.0...v0.42.0
WORKSPACE
codeload("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
sha256 = "91585017debb61982f7054c9688857a2ad1fd823fc3f9cb05048b0025c47d023",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.42.0/rules_go-v0.42.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.42.0/rules_go-v0.42.0.zip",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.21.1")
Starting this release, rules_go no longer ship with @go_googleapis
repo. Together with Gazelle v0.32.0, it means that all Go code importing generated code from Google APIs will depend on @org_golang_google_genproto
, which is resolved by Go modules. For proto files importing Google APIs proto and generating Go code, users need to:
http_archive
rule to download Google APIs, e.g.,http_archive(
name = "googleapis",
sha256 = "9d1a930e767c93c825398b8f8692eca3fe353b9aaadedfbcf1fca2282c85df88",
strip_prefix = "googleapis-64926d52febbf298cb82a8f472ade4a3969ba922",
urls = [
"https://github.com/googleapis/googleapis/archive/64926d52febbf298cb82a8f472ade4a3969ba922.zip",
],
)
load("@googleapis//:repository_rules.bzl", "switched_rules_by_language")
switched_rules_by_language(
name = "com_google_googleapis_imports",
)
Note that the version of Google APIs archive needs to be compatible with the pre-generated code in @org_golang_google_genproto
.
# gazelle:resolve proto proto google/rpc/status.proto @googleapis//google/rpc:status_proto
# gazelle:resolve proto go google/rpc/status.proto @org_golang_google_genproto//googleapis/rpc/status
# gazelle:resolve proto google/longrunning/operations.proto @googleapis//google/longrunning:operations_proto
# gazelle:resolve proto go google/longrunning/operations.proto @org_golang_google_genproto//googleapis/longrunning
Other changes included in this release
go_sdk
extension failure for unnamed root module by @fmeum in https://github.com/bazelbuild/rules_go/pull/3612
Full Changelog: https://github.com/bazelbuild/rules_go/compare/v0.40.1...v0.41.0
WORKSPACE
codeload("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
sha256 = "278b7ff5a826f3dc10f04feaf0b70d48b68748ccd512d7f98bf442077f043fe3",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.41.0/rules_go-v0.41.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.41.0/rules_go-v0.41.0.zip",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.20.5")
WORKSPACE
codeload("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
sha256 = "51dc53293afe317d2696d4d6433a4c33feedb7748a9e352072e2ec3c0dafd2c6",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.40.1/rules_go-v0.40.1.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.40.1/rules_go-v0.40.1.zip",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.20.5")
This patch release cherry-picked two bug fixes related to Go package driver from master