Releases: bazel-contrib/rules_go
0.10.2
New Go versions
rules_go now supports Go 1.10.1 and 1.9.5.
Bug fixes
- #1407 - Include import paths in coverage file names
- #1408 - Remove mapping for local_config_cc to fix problems when the generation is updated.
- #1394 - protoc: create trivial files for missing outputs
- #1388 - proto: embed doesn't have GoProtoImports provider
- #1387 - Save test coverage data to bazel-testlogs.
- #1382 - Handle Windows long file names in a few more places.
- #1355 - generate_test: implement example testing
- #1363 - Fix error check in stdlib builder
WORKSPACE code
To use this release, add this code to your WORKSPACE file:
http_archive(
name = "io_bazel_rules_go",
url = "https://github.com/bazelbuild/rules_go/releases/download/0.10.2/rules_go-0.10.2.tar.gz",
sha256 = "4b2c61795ac2eefcb28f3eb8e1cb2d8fb3c2eafa0f6712473bc5f93728f38758",
)
load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
go_rules_dependencies()
go_register_toolchains()
0.10.1
Bug fixes
- #1342 - Don't force external linking for static builds
- #1344 - Remove previously copied files before building stdlib
- #1346 - compile: set -p to the actual import path, not the source import path
- #1348 - stdlib: dereference all symlinks before copying a directory
- #1349 - overlay repositories: resolve labels before downloading
WORKSPACE code
To use this release, add this code to your WORKSPACE file:
http_archive(
name = "io_bazel_rules_go",
url = "https://github.com/bazelbuild/rules_go/releases/download/0.10.1/rules_go-0.10.1.tar.gz",
sha256 = "4b14d8dd31c6dbaf3ff871adcd03f28c3274e42abc855cb8fb4d01233c0154dc",
)
load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
go_rules_dependencies()
go_register_toolchains()
0.10.0
Go rules
- Support for Go 1.10, 1.9.3, 1.9.4, 1.8.6, and 1.8.7.
go_library
supports a new attribute,importmap
. This lets you set the "actual" import path of a library, which is what the compiler and linker will see. This is only needed when linking binaries that include multiple packages with the same import path.importpath
is still the name by which libraries are imported by source files in other libraries.go_test
may now include sources from both internal tests (compiled in the same archive as the code under test) and external tests (compiled in a separate archive).go_test
now recognizes the standardshard_count
attribute (see Attributes common to all test rules).- Removed
wtool
. Usegazelle update-repos example.com/repo
instead. - Removed old Gazelle tree. Use
github.com/bazelbuild/bazel-gazelle
instead.
WORKSPACE code
To use this release, add this code to your WORKSPACE file:
http_archive(
name = "io_bazel_rules_go",
url = "https://github.com/bazelbuild/rules_go/releases/download/0.10.0/rules_go-0.10.0.tar.gz",
sha256 = "53c8222c6eab05dd49c40184c361493705d4234e60c42c4cd13ab4898da4c6be",
)
load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
go_rules_dependencies()
go_register_toolchains()
Direct download: rules_go-0.10.0.tar.gz
0.9.0
Go rules
- Support for transitive link stamping. You can now set
x_defs
attributes ingo_library
rules. Any binary rules that depend on those libraries (directly or transitively) will apply those definitions at link time. See Defines and Stamping for more information. - Refactored rules and toolchain internals. This doesn't affect normal usage of Go rules, but if you maintain Bazel rules that depend on Go providers and toolchains, see documentation in go/toolchains.rst, especially on
GoContext
andgo_context
. - The
library
attribute is now deprecated. Please migrate toembed
instead.gazelle fix
will do this for you automatically. - Several fixes for cgo, Windows, and ppc64.
- Fixed a bug in the code used to check the minimum Bazel version.
Proto rules
- Support for gogo proto. See
GOGO_VARIANTS
in proto/BUILD.bazel for available compiler plugins. See gogo/BUILD.bazel for an example. - Proto files no longer need to set
option go_package
, and the protopackage
doesn't need to match theimportpath
explicitly set ingo_proto_library
.
Gazelle
Reminder: the old Gazelle tree at go/tools/gazelle is deprecated and will be removed soon (#1199). The new location is github.com/bazelbuild/bazel-gazelle. Please update any tooling you have that builds Gazelle at master.
WORKSPACE code
To use this release, add this code to your WORKSPACE file:
http_archive(
name = "io_bazel_rules_go",
url = "https://github.com/bazelbuild/rules_go/releases/download/0.9.0/rules_go-0.9.0.tar.gz",
sha256 = "4d8d6244320dd751590f9100cf39fd7a4b75cd901e1f3ffdfd6f048328883695",
)
load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
go_rules_dependencies()
go_register_toolchains()
Direct download: rules_go-0.9.0.tar.gz
0.8.1
Go rules
go_binary
now supportsgoos
andgoarch
attributes. This enables multiple target platforms in the same build.- Fixed an issue which caused the build to fail with the message: "Unsupported architecture: unknown" on newer Linux distributions. We now default to amd64 when we can't detect the architecture with
uname -p
on Linux. - Multiple fixes for builds with
--features=pure
and--features=race
.
Gazelle
# gazelle:prefix example.com/repo
can be used to set the prefix within a subtree.- Fixed some logic bugs around dependency resolution, deletion of rules, and
# gazelle:ignore
.
WORKSPACE code
To use this release, add this code to your WORKSPACE file:
http_archive(
name = "io_bazel_rules_go",
url = "https://github.com/bazelbuild/rules_go/releases/download/0.8.1/rules_go-0.8.1.tar.gz",
sha256 = "90bb270d0a92ed5c83558b2797346917c46547f6f7103e648941ecdb6b9d0e72",
)
load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
go_rules_dependencies()
go_register_toolchains()
Direct download: rules_go-0.8.1.tar.gz
0.8.0
Go rules
- Minimum Bazel version is now 0.8.0.
- The
config_setting
rules in//go/platform
are now based onconstraint_values
instead ofcpu
. This means that you can writeselect
expressions that match any platform that the Go SDK targets. - Go executable files now end with ".exe" on Windows.
- Output paths have changed for nearly all rules to include the target platform and configuration. This preserves the cache when targets are built in different configurations.
- Fixed cgo tag filtering for "pure" builds.
- Support for linux/s390x as a host platform (thanks to @kadamvandita).
Proto rules
- The proto compiler is now selected using an explicit
compiler
attribute ingo_proto_library
. We no longer use toolchains for this. This lets you use different plugins for different proto libraries. go_grpc_library
is now a macro aroundgo_proto_library
with a gRPC plugin. We plan to deprecate this soon.
Gazelle changes
- Gazelle builds an index of all libraries in a repository and uses the index to resolve dependencies. This enables multiple vendor directories, Go subtrees not at the repository root, and more.
# gazelle:exclude
can be used to ignore paths in subdirectories, not just files in the current directory.- Removed the experimental flat mode. We planned to use flat files with
new_http_archive
/new_git_repository
, but this would cause unnecessary work when migrating repositories to Bazel. We're exploring other solutions.
WORKSPACE code
To use this release, add this code to your WORKSPACE file:
http_archive(
name = "io_bazel_rules_go",
url = "https://github.com/bazelbuild/rules_go/releases/download/0.8.0/rules_go-0.8.0.tar.gz",
sha256 = "8eaf2e62811169d9cf511209153effcb132826cea708b2f75d4dd5f9e57ea2aa",
)
load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
go_rules_dependencies()
go_register_toolchains()
Direct download: rules_go-0.8.0.tar.gz
0.7.1
Bug fixes and small features
This is a fairly small release with a few bug fixes and small features. This is the last release before we upgrade to Bazel 0.8, which incorporates several features for cross-platform support which we plan to use as soon as possible.
The following changes are included in this release:
- Bazel 0.7 is now the minimum Bazel version.
- Several bug fixes for aspect-based builds. This mostly affects
"pure"
mode and cross-compilation. - Several fixes for performance regressions. This resolved some restructuring of our providers to avoid hashing a large amount of data in depsets.
- Gazelle converts
library
attributes toembed
. These attributes cover the same concept, butembed
accepts a list of targets instead of one. go_source
is a new rule which specifies a group ofsrcs
anddeps
that can be used as a target inembed
attributes. Unlikego_library
, these rules cannot be built independently.- Dropped support for Go 1.7.
WORKSPACE code
To use this release, add this code to your WORKSPACE file:
http_archive(
name = "io_bazel_rules_go",
url = "https://github.com/bazelbuild/rules_go/releases/download/0.7.1/rules_go-0.7.1.tar.gz",
sha256 = "341d5eacef704415386974bc82a1783a8b7ffbff2ab6ba02375e1ca20d9b031c",
)
load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
go_rules_dependencies()
go_register_toolchains()
Direct download: rules_go-0.7.1.tar.gz
0.7.0
Improved cross-compilation
You can now cross-compile pure Go binaries (without cgo) for any platform that Go supports. For example:
bazel build --experimental_platforms=@io_bazel_rules_go//go/toolchain:linux_s390x //:my_binary
Just change the platform target to any GOOS / GOARCH combination supported by the Go SDK.
There are still a few known issues. In particular, the current version of Bazel doesn't allow us to add .exe extensions to binary files on Windows. This will be fixed in Bazel 0.8, so we'll tag another release with that as the minimum supported version as soon as it's available.
Improved build mode support
You can now build static, race, msan, and tsan binaries using Bazel feature flags. For example:
bazel build --features=static,msan //:my_binary
You can also specify static and pure modes on go_binary
rules using new attributes. This is useful if you have packaging rules that depend on binary rules built in specific configurations.
go_binary(
name = "my_binary",
...,
static = "on",
)
The old mechanism of using output groups to select build mode has been removed.
See build modes for more information.
Gazelle multi-platform support
Gazelle can generate build files that work on all platforms that Go supports. In order to avoid repetition, we've divided sources, dependencies, and options into separate OS-specific, arch-specific, and OS-and-arch-specific select
expressions. For example:
go_library(
name = "go_default_library",
srcs = [
"foo.go",
] + select({
"@io_bazel_rules_go//go/platform:linux": [
"foo_linux.go",
],
"//conditions:default": [],
}) + select({
"@io_bazel_rules_go//go/platform:amd64": [
"foo_amd64.go",
],
"//conditions:default": [],
}),
importpath = "github.com/example/project",
visibility = ["//visibility:public"],
)
This new functionality is off by default; you can try it out with the -experimental_platforms
flag.
At this time, the config_setting
rules in @io_bazel_rules_go//go/platform
can only match the cpu
value, which means we are limited to platforms where Bazel has a C++ toolchain. With Bazel 0.8, config_setting
rules will be able to match constraint_values
, which gives us much more flexibility. After that release, we'll remove the -experimental_platforms
flag and turn on the new functionality.
WORKSPACE code
To use this release, add this code to your WORKSPACE file:
http_archive(
name = "io_bazel_rules_go",
url = "https://github.com/bazelbuild/rules_go/releases/download/0.7.0/rules_go-0.7.0.tar.gz",
sha256 = "91fca9cf860a1476abdc185a5f675b641b60d3acf0596679a27b580af60bf19c",
)
load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
go_rules_dependencies()
go_register_toolchains()
Direct download: rules_go-0.7.0.tar.gz
0.6.0
Go Rules
- Go 1.8.4, 1.9, and 1.9.1 are now supported. The default SDK is now 1.9.1.
- Major documentation overhaul (still in progress).
- Rules now support an
importpath
attribute, which allows import paths to be set explicitly. If all rules in a repository use this,go_prefix
is not needed. - Rules also support an
embed
attribute, which allows sources, dependencies, and data from multiple libraries to be combined. This is the same concept as thelibrary
attribute, but multiple libraries may be embedded instead of just one. GoLibrary
,GoBinary
, andGoEmbed
providers are now documented. These can be used to write rules compatible with the Go rules.- Actions are now specified using toolchains, which were recently added to Bazel.
go_register_toolchains()
must be called in WORKSPACE in order to make Bazel aware of toolchains. - Experimental: Cross compilation is supported using the new toolchains. Currently, only darwin-amd64 to linux-amd64 works, but we are working on supporting more platforms. You can try this with
--cpu k8
. - Experimental: New protocol buffer rules
go_proto_library
andgo_grpc_library
are defined inproto/def.bzl
. This is a complete rewrite of proto support. The interface is not finalized yet and may change.
Gazelle
- New protocol buffer rules are now generated for .proto files if other proto rules are not present already. Gazelle will replace the old rules when the
fix
command is used. - Rules that were generated by Gazelle are now removed if they are empty. For example, if all of the _test.go files are removed from a directory, Gazelle will delete the
go_test
rules. - Some Gazelle command line options may be specified using directives. Directives are special comments in build files, for example,
# gazelle:build_tags foo,bar
. - Added an experimental flat mode. In this mode, Gazelle will generate a single build file for an entire repository. This is intended to be used with
new_http_archive
andnew_git_repository
once we deprecatego_repository
. You can try this out with the-experimental_flat
command line option.
WORKSPACE code
To use this release, add this code to your WORKSPACE file:
http_archive(
name = "io_bazel_rules_go",
url = "https://github.com/bazelbuild/rules_go/releases/download/0.6.0/rules_go-0.6.0.tar.gz",
sha256 = "ba6feabc94a5d205013e70792accb6cce989169476668fbaf98ea9b342e13b59",
)
load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
go_rules_dependencies()
go_register_toolchains()
Direct download: rules_go-0.6.0.tar.gz
0.5.5
This is a bug fix release, needed for #820. We fetched some of our dependencies using http_archive
rules with sha256 sums. The tarballs downloaded by these rules are generated by GitHub on the fly and are not guaranteed to have a stable sha256 hash. We discovered this yesterday when the hashes changed due to a GitHub OS update.
With this release, all dependencies are fetched using either git_repository
, http_archive
with a known-stable sha256, or http_archive
without sha256 from GitHub via HTTPS.
With this release and future releases, we will include a link to a stable archive of this repository and a sha256 sum so that developers may continue to use http_archive
.
rules_go-0.5.5.tar.gz - sha256: ca58b0b856dc95473b93f2228ab117913b82a6617fc0deabd107346e3981522a