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