Go rules for Bazel

Overview

Go rules for Bazel

Mailing list: bazel-go-discuss

Slack: #go on Bazel Slack, #bazel on Go Slack

Announcements

2021-10-06
Release v0.29.0 is now available. This enables nogo analyzers to depend on go_library rules, removes the rules_cc dependency, adds automatic target detection to gopackagesdriver, and fixes some cgo-related bugs. See the release notes for details.
2021-07-07
Release v0.28.0 is now available. This adds experimental editor support, plus a few other changes. See the release notes for details. Thanks to all who contributed!
2021-03-18
Release v0.27.0 is now available. This updates org_golang_x_tools and adds org_golang_x_sys. This should have been done in v0.26.0. Additionally, v0.24.14 is now available with support for Go 1.16.2, 1.16.1, 1.15.10, and 1.15.9. This will be the last release on the 0.24 branch. 0.27 and 0.25 are now the two supported branches.
2021-03-08
Release v0.26.0 is now available. This provides support for the new //go:embed attribute, plus several other improvements. Gazelle v0.23.0 is also available with support for embedsrcs attributes (needed for //go:embed) and a few other improvements.

Contents

Documentation

Quick links

Overview

The rules are in the beta stage of development. They support:

They currently do not support or have limited support for:

The Go rules are tested and supported on the following host platforms:

  • Linux, macOS, Windows
  • amd64

Users have reported success on several other platforms, but the rules are only tested on those listed above.

Note: The latest version of these rules (v0.28.0) requires Bazel ≥ 4.0.0 to work.

The master branch is only guaranteed to work with the latest version of Bazel.

Setup

System setup

To build Go code with Bazel, you will need:

  • A recent version of Bazel.
  • A C/C++ toolchain (if using cgo). Bazel will attempt to configure the toolchain automatically.
  • Bash, patch, cat, and a handful of other Unix tools in PATH.

You normally won't need a Go toolchain installed. Bazel will download one.

See Using rules_go on Windows for Windows-specific setup instructions. Several additional tools need to be installed and configured.

Initial project setup

Create a file at the top of your repository named WORKSPACE, and add the snippet below (or add to your existing WORKSPACE). This tells Bazel to fetch rules_go and its dependencies. Bazel will download a recent supported Go toolchain and register it for use.

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "io_bazel_rules_go",
    sha256 = "2b1641428dff9018f9e85c0384f03ec6c10660d935b750e3fa1492a281a53b0f",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.29.0/rules_go-v0.29.0.zip",
        "https://github.com/bazelbuild/rules_go/releases/download/v0.29.0/rules_go-v0.29.0.zip",
    ],
)

load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

go_rules_dependencies()

go_register_toolchains(version = "1.17.1")

You can use rules_go at master by using git_repository instead of http_archive and pointing to a recent commit.

Add a file named BUILD.bazel in the root directory of your project. You'll need a build file in each directory with Go code, but you'll also need one in the root directory, even if your project doesn't have Go code there. For a "Hello, world" binary, the file should look like this:

load("@io_bazel_rules_go//go:def.bzl", "go_binary")

go_binary(
    name = "hello",
    srcs = ["hello.go"],
)

You can build this target with bazel build //:hello.

Generating build files

If your project can be built with go build, you can generate and update your build files automatically using gazelle.

Add the bazel_gazelle repository and its dependencies to your WORKSPACE. It should look like this:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "io_bazel_rules_go",
    sha256 = "8e968b5fcea1d2d64071872b12737bbb5514524ee5f0a4f54f5920266c261acb",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.28.0/rules_go-v0.28.0.zip",
        "https://github.com/bazelbuild/rules_go/releases/download/v0.28.0/rules_go-v0.28.0.zip",
    ],
)

http_archive(
    name = "bazel_gazelle",
    sha256 = "de69a09dc70417580aabf20a28619bb3ef60d038470c7cf8442fafcf627c21cb",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz",
        "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz",
    ],
)

load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")

go_rules_dependencies()

go_register_toolchains(version = "1.17.2")

gazelle_dependencies()

Add the code below to the BUILD.bazel file in your project's root directory. Replace the string after prefix with an import path prefix that matches your project. It should be the same as your module path, if you have a go.mod file.

load("@bazel_gazelle//:def.bzl", "gazelle")

# gazelle:prefix github.com/example/project
gazelle(name = "gazelle")

This declares a gazelle binary rule, which you can run using the command below:

bazel run //:gazelle

This will generate a BUILD.bazel file with go_library, go_binary, and go_test targets for each package in your project. You can run the same command in the future to update existing build files with new source files, dependencies, and options.

Writing build files by hand

If your project doesn't follow go build conventions or you prefer not to use gazelle, you can write build files by hand.

In each directory that contains Go code, create a file named BUILD.bazel Add a load statement at the top of the file for the rules you use.

load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")

For each library, add a go_library rule like the one below. Source files are listed in the srcs attribute. Imported packages outside the standard library are listed in the deps attribute using Bazel labels that refer to corresponding go_library rules. The library's import path must be specified with the importpath attribute.

go_library(
    name = "foo_library",
    srcs = [
        "a.go",
        "b.go",
    ],
    importpath = "github.com/example/project/foo",
    deps = [
        "//tools",
        "@org_golang_x_utils//stuff",
    ],
    visibility = ["//visibility:public"],
)

For tests, add a go_test rule like the one below. The library being tested should be listed in an embed attribute.

go_test(
    name = "foo_test",
    srcs = [
        "a_test.go",
        "b_test.go",
    ],
    embed = [":foo_lib"],
    deps = [
        "//testtools",
        "@org_golang_x_utils//morestuff",
    ],
)

For binaries, add a go_binary rule like the one below.

go_binary(
    name = "foo",
    srcs = ["main.go"],
)

Adding external repositories

For each Go repository, add a go_repository rule to WORKSPACE like the one below. This rule comes from the Gazelle repository, so you will need to load it. gazelle update-repos can generate or update these rules automatically from a go.mod or Gopkg.lock file.

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# Download the Go rules.
http_archive(
    name = "io_bazel_rules_go",
    sha256 = "2b1641428dff9018f9e85c0384f03ec6c10660d935b750e3fa1492a281a53b0f",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.29.0/rules_go-v0.29.0.zip",
        "https://github.com/bazelbuild/rules_go/releases/download/v0.29.0/rules_go-v0.29.0.zip",
    ],
)

# Download Gazelle.
http_archive(
    name = "bazel_gazelle",
    sha256 = "de69a09dc70417580aabf20a28619bb3ef60d038470c7cf8442fafcf627c21cb",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz",
        "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz",
    ],
)

# Load macros and repository rules.
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")

# Declare Go direct dependencies.
go_repository(
    name = "org_golang_x_net",
    importpath = "golang.org/x/net",
    sum = "h1:zK/HqS5bZxDptfPJNq8v7vJfXtkU7r9TLIoSr1bXaP4=",
    version = "v0.0.0-20200813134508-3edf25e44fcc",
)

# Declare indirect dependencies and register toolchains.
go_rules_dependencies()

go_register_toolchains(version = "1.17")

gazelle_dependencies()

protobuf and gRPC

To generate code from protocol buffers, you'll need to add a dependency on com_google_protobuf to your WORKSPACE.

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "com_google_protobuf",
    sha256 = "d0f5f605d0d656007ce6c8b5a82df3037e1d8fe8b121ed42e536f569dec16113",
    strip_prefix = "protobuf-3.14.0",
    urls = [
        "https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v3.14.0.tar.gz",
        "https://github.com/protocolbuffers/protobuf/archive/v3.14.0.tar.gz",
    ],
)

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()

You'll need a C/C++ toolchain registered for the execution platform (the platform where Bazel runs actions) to build protoc.

The proto_library rule is provided by the rules_proto repository. protoc-gen-go, the Go proto compiler plugin, is provided by the com_github_golang_protobuf repository. Both are declared by go_rules_dependencies. You won't need to declare an explicit dependency unless you specifically want to use a different version. See Overriding dependencies for instructions on using a different version.

gRPC dependencies are not declared by default (there are too many). You can declare them in WORKSPACE using go_repository. You may want to use gazelle update-repos to import them from go.mod.

See Proto dependencies, gRPC dependencies for more information. See also Avoiding conflicts.

Once all dependencies have been registered, you can declare proto_library and go_proto_library rules to generate and compile Go code from .proto files.

load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")

proto_library(
    name = "foo_proto",
    srcs = ["foo.proto"],
    deps = ["//bar:bar_proto"],
    visibility = ["//visibility:public"],
)

go_proto_library(
    name = "foo_go_proto",
    importpath = "github.com/example/protos/foo_proto",
    protos = [":foo_proto"],
    visibility = ["//visibility:public"],
)

A go_proto_library target may be imported and depended on like a normal go_library.

Note that recent versions of rules_go support both APIv1 (github.com/golang/protobuf) and APIv2 (google.golang.org/protobuf). By default, code is generated with github.com/golang/protobuf/cmd/protoc-gen-gen for compatibility with both interfaces. Client code may import use either runtime library or both.

FAQ

Go

Protocol buffers

Dependencies and testing

Can I still use the go command?

Yes, but not directly.

rules_go invokes the Go compiler and linker directly, based on the targets described with go_binary and other rules. Bazel and rules_go together fill the same role as the go command, so it's not necessary to use the go command in a Bazel workspace.

That said, it's usually still a good idea to follow conventions required by the go command (e.g., one package per directory, package paths match directory paths). Tools that aren't compatible with Bazel will still work, and your project can be depended on by non-Bazel projects.

Does this work with Go modules?

Yes, but not directly. Bazel ignores go.mod files, and all package dependencies must be expressed through deps attributes in targets described with go_library and other rules.

You can download a Go module at a specific version as an external repository using go_repository, a workspace rule provided by gazelle. This will also generate build files using gazelle.

You can import go_repository rules from a go.mod file using gazelle update-repos.

What's up with the go_default_library name?

This was used to keep import paths consistent in libraries that can be built with go build before the importpath attribute was available.

In order to compile and link correctly, rules_go must know the Go import path (the string by which a package can be imported) for each library. This is now set explicitly with the importpath attribute. Before that attribute existed, the import path was inferred by concatenating a string from a special go_prefix rule and the library's package and label name. For example, if go_prefix was github.com/example/project, for a library //foo/bar:bar, rules_go would infer the import path as github.com/example/project/foo/bar/bar. The stutter at the end is incompatible with go build, so if the label name was go_default_library, the import path would not include it. So for the library //foo/bar:go_default_library, the import path would be github.com/example/project/foo/bar.

Since go_prefix was removed and the importpath attribute became mandatory (see #721), the go_default_library name no longer serves any purpose. We may decide to stop using it in the future (see #265).

How do I cross-compile?

You can cross-compile by setting the --platforms flag on the command line. For example:

$ bazel build [email protected]_bazel_rules_go//go/toolchain:linux_amd64 //cmd

By default, cgo is disabled when cross-compiling. To cross-compile with cgo, add a _cgo suffix to the target platform. You must register a cross-compiling C/C++ toolchain with Bazel for this to work.

$ bazel build [email protected]_bazel_rules_go//go/toolchain:linux_amd64_cgo //cmd

Platform-specific sources with build tags or filename suffixes are filtered automatically at compile time. You can selectively include platform-specific dependencies with select expressions (Gazelle does this automatically).

go_library(
    name = "foo",
    srcs = [
        "foo_linux.go",
        "foo_windows.go",
    ],
    deps = select({
        "@io_bazel_rules_go//go/platform:linux_amd64": [
            "//bar_linux",
        ],
        "@io_bazel_rules_go//go/platform:windows_amd64": [
            "//bar_windows",
        ],
        "//conditions:default": [],
    }),
)

To build a specific go_binary or go_test target for a target platform, set the goos and goarch attributes on that rule. This is useful for producing multiple binaries for different platforms in a single build. You can equivalently depend on a go_binary or go_test rule through a Bazel configuration transition on //command_line_option:platforms (there are problems with this approach prior to rules_go 0.23.0).

How do I access testdata?

Bazel executes tests in a sandbox, which means tests don't automatically have access to files. You must include test files using the data attribute. For example, if you want to include everything in the testdata directory:

go_test(
    name = "foo_test",
    srcs = ["foo_test.go"],
    data = glob(["testdata/**"]),
    importpath = "github.com/example/project/foo",
)

By default, tests are run in the directory of the build file that defined them. Note that this follows the Go testing convention, not the Bazel convention followed by other languages, which run in the repository root. This means that you can access test files using relative paths. You can change the test directory using the rundir attribute. See go_test.

Gazelle will automatically add a data attribute like the one above if you have a testdata directory unless it contains buildable .go files or build files, in which case, testdata is treated as a normal package.

Note that on Windows, data files are not directly available to tests, since test data files rely on symbolic links, and by default, Windows doesn't let unprivileged users create symbolic links. You can use the github.com/bazelbuild/rules_go/go/tools/bazel library to access data files.

How do I access go_binary executables from go_test?

The location where go_binary writes its executable file is not stable across rules_go versions and should not be depended upon. The parent directory includes some configuration data in its name. This prevents Bazel's cache from being poisoned when the same binary is built in different configurations. The binary basename may also be platform-dependent: on Windows, we add an .exe extension.

To depend on an executable in a go_test rule, reference the executable in the data attribute (to make it visible), then expand the location in args. The real location will be passed to the test on the command line. For example:

go_binary(
    name = "cmd",
    srcs = ["cmd.go"],
)

go_test(
    name = "cmd_test",
    srcs = ["cmd_test.go"],
    args = ["$(location :cmd)"],
    data = [":cmd"],
)

See //tests/core/cross for a full example of a test that accesses a binary.

Alternatively, you can set the out attribute of go_binary to a specific filename. Note that when out is set, the binary won't be cached when changing configurations.

go_binary(
    name = "cmd",
    srcs = ["cmd.go"],
    out = "cmd",
)

go_test(
    name = "cmd_test",
    srcs = ["cmd_test.go"],
    data = [":cmd"],
)

How do I avoid conflicts with protocol buffers?

See Avoiding conflicts in the proto documentation.

Can I use a vendored gRPC with go_proto_library?

This is not supported. When using go_proto_library with the @io_bazel_rules_go//proto:go_grpc compiler, an implicit dependency is added on @org_golang_google_grpc//:go_default_library. If you link another copy of the same package from //vendor/google.golang.org/grpc:go_default_library or anywhere else, you may experience conflicts at compile or run-time.

If you're using Gazelle with proto rule generation enabled, imports of google.golang.org/grpc will be automatically resolved to @org_golang_google_grpc//:go_default_library to avoid conflicts. The vendored gRPC should be ignored in this case.

If you specifically need to use a vendored gRPC package, it's best to avoid using go_proto_library altogether. You can check in pre-generated .pb.go files and build them with go_library rules. Gazelle will generate these rules when proto rule generation is disabled (add # gazelle:proto disable_global to your root build file).

How do I use different versions of dependencies?

See Overriding dependencies for instructions on overriding repositories declared in go_rules_dependencies.

How do I run Bazel on Travis CI?

References:

In order to run Bazel tests on Travis CI, you'll need to install Bazel in the before_install script. See our configuration file linked above.

You'll want to run Bazel with a number of flags to prevent it from consuming a huge amount of memory in the test environment.

  • --host_jvm_args=-Xmx500m --host_jvm_args=-Xms500m: Set the maximum and initial JVM heap size. Keeping the same means the JVM won't spend time growing the heap. The choice of heap size is somewhat arbitrary; other configuration files recommend limits as high as 2500m. Higher values mean a faster build, but higher risk of OOM kill.
  • --bazelrc=.test-bazelrc: Use a Bazel configuration file specific to Travis CI. You can put most of the remaining options in here.
  • build --spawn_strategy=standalone --genrule_strategy=standalone: Disable sandboxing for the build. Sandboxing may fail inside of Travis's containers because the mount system call is not permitted.
  • test --test_strategy=standalone: Disable sandboxing for tests as well.
  • --local_resources=1536,1.5,0.5: Set Bazel limits on available RAM in MB, available cores for compute, and available cores for I/O. Higher values mean a faster build, but higher contention and risk of OOM kill.
  • --noshow_progress: Suppress progress messages in output for cleaner logs.
  • --verbose_failures: Get more detailed failure messages.
  • --test_output=errors: Show test stderr in the Travis log. Normally, test output is written log files which Travis does not save or report.

Downloads on Travis are relatively slow (the network is heavily contended), so you'll want to minimize the amount of network I/O in your build. Downloading Bazel and a Go SDK is a huge part of that. To avoid downloading a Go SDK, you may request a container with a preinstalled version of Go in your .travis.yml file, then call go_register_toolchains(go_version = "host") in a Travis-specific WORKSPACE file.

You may be tempted to put Bazel's cache in your Travis cache. Although this can speed up your build significantly, Travis stores its cache on Amazon, and it takes a very long time to transfer. Clean builds seem faster in practice.

How do I test a beta version of the Go SDK?

rules_go only supports official releases of the Go SDK. However, you can still test beta and RC versions by passing a version like "1.16beta1" to go_register_toolchains. See also go_download_sdk.

load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

go_rules_dependencies()

go_register_toolchains(version = "1.17beta1")
Comments
  • runfiles.Rlocation library returns relative paths

    runfiles.Rlocation library returns relative paths

    What version of rules_go are you using?

    v0.36.0

    What version of gazelle are you using?

    n/a

    What version of Bazel are you using?

    5.3.2

    Does this issue reproduce with the latest releases of all the above?

    Yes.

    What operating system and processor architecture are you using?

    Linux amd64.

    Any other potentially useful information about your toolchain?

    What did you do?

    Documentation says "// Rlocation returns the absolute path name of a runfile", but I am getting "bazel-out/k8-opt-exec-2B5CBBC6/bin/bazel/web/targets/plugin/plugin_/plugin.runfiles/bazel/web/targets/protoc-gen-ts-proto."

    The Go binary is executing within a genrule, FWIW.

    What did you expect to see?

    An absolute path in the output.

    What did you see instead?

    An relative path in the output.

    opened by gonzojive 0
  • New runfiles library is missing `listRunfiles`

    New runfiles library is missing `listRunfiles`

    What version of rules_go are you using?

    v0.36.0

    What version of Bazel are you using?

    5.3.2

    Does this issue reproduce with the latest releases of all the above?

    Yes

    What operating system and processor architecture are you using?

    Linux

    Any other potentially useful information about your toolchain?

    What did you do?

    Started using the new recommended runfiles library and tried to call ListRunfiles().

    What did you expect to see?

    Same feature available as in the github.com/bazelbuild/rules_go/go/tools/bazel library.

    What did you see instead?

    A listRunfiles function in the new library.

    My typical usage

    I often mess up runfile paths. To make the error more readable, I suggest a similarly named file in the error message.

    package runfileutil
    
    import (
    	"errors"
    	"fmt"
    	"os"
    	"path"
    	"strings"
    
    	runfiles1p "github.com/bazelbuild/rules_go/go/runfiles"
    	"github.com/bazelbuild/rules_go/go/tools/bazel"
    )
    
    // Runfile returns an absolute path to the file named by "path", which should be
    // a relative path from the workspace root to the file within the bazel
    // workspace.
    //
    // Runfile may be called from tests invoked with 'bazel test' and binaries
    // invoked with 'bazel run'. On Windows, only tests invoked with 'bazel test'
    // are supported.
    //
    // If the runfile isn't found, an error is returned that suggests
    // similarly-named runfiles.
    func Runfile(filePath string) (string, error) {
    	got, err := runfiles1p.Rlocation(filePath)
    	if err == nil {
    		return got, nil
    	}
    	if err != nil && strings.Contains(err.Error(), "could not locate file") {
    		err = fmt.Errorf("%s: %w", err, os.ErrNotExist)
    	}
    
    	if !errors.Is(err, os.ErrNotExist) {
    		return "", fmt.Errorf("unknown error locating runfile %q: %w", filePath, err)
    	}
    	base := path.Base(filePath)
    	entries, err := bazel.ListRunfiles()
    	if err != nil {
    		return "", fmt.Errorf("could not locate %q: failed to list runfile entries: %w", filePath, err)
    	}
    	sameBaseEntries := filter(entries, func(entry bazel.RunfileEntry) bool {
    		return path.Base(entry.ShortPath) == base
    	})
    
    	if len(sameBaseEntries) == 0 {
    		return "", fmt.Errorf("could not locate %q among %d runfiles:\n  %s", filePath, len(entries),
    			strings.Join(mapSlice(entries, func(e bazel.RunfileEntry) string { return e.ShortPath }), "\n  "))
    	}
    	return "", fmt.Errorf("could not locate %q among %d runfiles; suggested match(es):\n  %s", filePath, len(entries),
    		strings.Join(mapSlice(sameBaseEntries, func(e bazel.RunfileEntry) string {
    			return fmt.Sprintf("%q", e.ShortPath)
    		}), "\n  "))
    
    	// var sameBaseShortPaths []*bazel.RunfileEntry
    	// for _, e := range entries {
    	// 	if path.Base(e.ShortPath)
    	// }
    }
    
    func mapSlice[T, R any](s []T, fn func(T) R) []R {
    	var out []R
    	for _, t := range s {
    		out = append(out, fn(t))
    	}
    	return out
    }
    
    func filter[T any](s []T, fn func(T) bool) []T {
    	var out []T
    	for _, t := range s {
    		if fn(t) {
    			out = append(out, t)
    		}
    	}
    	return out
    }
    
    
    opened by gonzojive 0
  • runfiles: error message `path

    runfiles: error message `path "...." is not normalized` should be instructive

    What version of rules_go are you using?

    v0.36.0

    What version of gazelle are you using?

    Not sure

    What version of Bazel are you using?

    5.3.2

    Does this issue reproduce with the latest releases of all the above?

    Yes.

    What operating system and processor architecture are you using?

    Linux

    Any other potentially useful information about your toolchain?

    n/a

    What did you do?

    runfiles.Rlocation("external/com_google_protobuf_javascript//generator/protoc-gen-js") returns an error that requires reading the code to understand:

    path "external/com_google_protobuf_javascript//generator/protoc-gen-js" is not normalized
    

    What did you expect to see?

    An error message that explains what corrective action should be taken.

    What did you see instead?

    See above.

    Suggested fix:

    func (r *Runfiles) Rlocation(path string) (string, error) {
    	if r.impl == nil {
    		return "", errors.New("runfiles: uninitialized Runfiles object")
    	}
    
    	if path == "" {
    		return "", errors.New("runfiles: path may not be empty")
    	}
    	if !isNormalizedPath(path) {
    		return "", fmt.Errorf("runfiles: path %q is not normalized", path)
    	}
    
    	// See https://github.com/bazelbuild/bazel/commit/b961b0ad6cc2578b98d0a307581e23e73392ad02
    	if strings.HasPrefix(path, `\`) {
    		return "", fmt.Errorf("runfiles: path %q is absolute without a drive letter", path)
    	}
    	if filepath.IsAbs(path) {
    		return path, nil
    	}
    
    	p, err := r.impl.path(path)
    	if err != nil {
    		return "", Error{path, err}
    	}
    	return p, nil
    }
    
    func isNormalizedPath(s string) bool {
    	return !strings.HasPrefix(s, "../") && !strings.Contains(s, "/..") &&
    		!strings.HasPrefix(s, "./") && !strings.HasSuffix(s, "/.") &&
    		!strings.Contains(s, "/./") && !strings.Contains(s, "//")
    }
    

    change isNormalizedPath() bool to checkNormalizedPath(s string) error that prints something like "path should not contain multiple adjacent slashes"

    opened by gonzojive 0
  • fix(gpd): Write large target patterns to file

    fix(gpd): Write large target patterns to file

    What type of PR is this?

    Bug fix

    What does this PR do? Why is it needed?

    In rare cases (querying an entire large repo for it's packages) our query will return too many targets to fit inside the arguments length for your system.

    Bazel added --target_pattern_file (https://github.com/bazelbuild/bazel/pull/10856) for this exact scenario. This implements that by creating a temp file with all the target patterns.

    Which issues(s) does this PR fix?

    N/A

    Other notes for review

    opened by JamyDev 0
  • Upgrade org_golang_x_tools to 0.3.0

    Upgrade org_golang_x_tools to 0.3.0

    org_golang_x_tools moved some packages and change the API for internal/facts package. Most notably, internal/lsp has been moved to the gopls module, so it's no longer part of org_golang_x_tools. As a result, tests/integration/popular_repos/popular_repos.py has to be updated.

    This PR also add third_party/org_golang_x_tools-visibility.patch, so we no longer need to hack Gazelle to set visibility for the facts package

    opened by linzhp 2
  • Extend gomock to allow passing an `source_importpath` instead of `library` when operating in source mode

    Extend gomock to allow passing an `source_importpath` instead of `library` when operating in source mode

    What type of PR is this?

    Feature

    What does this PR do? Why is it needed?

    This PR adds a new parameter, importpath to the gomock rule. This parameter is optional, and allows a gomock target running in source mode to avoid depending on a go_library. As far as I can see, the only use for the go_library in source mode is to extract an importpath.

    I've also extended the test cases to test the different modes gomock can operate in, and made sure there's a link to gomock on the top level README.

    Which issues(s) does this PR fix?

    Fixes #3349

    opened by ramenjosh 2
Releases(v0.36.0)
  • v0.36.0(Nov 23, 2022)

    Major new features

    • The Go runfiles library developed by @phst at https://github.com/phst/runfiles is now available as github.com/bazelbuild/rules_go/go/runfiles (target @io_bazel_rules_go//go/runfiles) and is now the official way to look up runfiles from Go. It will be made compatible with Bzlmod in a future release. Note: For improved consistency with runfiles libraries in other languages, the Path function present in https://github.com/phst/runfiles is called Rlocation in rules_go.
    • Adding two new command line flags [email protected]_bazel_rules_go//go/config:gc_goopts and [email protected]_bazel_rules_go//go/config:gc_linkopts to accept additional compiler and linker flags.

    What's Changed

    • bzlmod: Use register_toolchains by @fmeum in https://github.com/bazelbuild/rules_go/pull/3290
    • Remove unused env_execute by @kmicklas in https://github.com/bazelbuild/rules_go/pull/3276
    • Correctly forward InstrumentedFilesInfo from dependencies by @fmeum in https://github.com/bazelbuild/rules_go/pull/3294
    • Parse Go SDK version out of go version instead of VERSION by @fmeum in https://github.com/bazelbuild/rules_go/pull/3296
    • also write test stderr to json (xml) output file by @rickystewart in https://github.com/bazelbuild/rules_go/pull/3300
    • Bzlmod: Pin Bazel version in CI by @fmeum in https://github.com/bazelbuild/rules_go/pull/3301
    • Allow to select Go SDK version from declared SDKs by @ash2k in https://github.com/bazelbuild/rules_go/pull/3303
    • Use top level VERSION file when it exists by @linzhp in https://github.com/bazelbuild/rules_go/pull/3309
    • synchronize when writing to the JSON converter by @rickystewart in https://github.com/bazelbuild/rules_go/pull/3311
    • update version manifest URL by @benjaminp in https://github.com/bazelbuild/rules_go/pull/3314
    • Symlink "misc" into repository for local_sdk. by @adam-azarchs in https://github.com/bazelbuild/rules_go/pull/3313
    • Ensure compatibility with incompatible flags close to flipping by @fmeum in https://github.com/bazelbuild/rules_go/pull/3319
    • Add additional bzlmod requirements to allow grpc protobufs to work by @shs96c in https://github.com/bazelbuild/rules_go/pull/3320
    • bzlmod: Update pinned Bazel version by @fmeum in https://github.com/bazelbuild/rules_go/pull/3321
    • bzlmod: Set up automated BCR releases by @fmeum in https://github.com/bazelbuild/rules_go/pull/3324
    • bzlmod: Add support for gogo proto compiler by @fmeum in https://github.com/bazelbuild/rules_go/pull/3323
    • gopackagesdriver: move non-Go files to OtherFiles (Fixes #3326) by @michaelarusso in https://github.com/bazelbuild/rules_go/pull/3327
    • bzlmod: Allow yanked versions in CI by @fmeum in https://github.com/bazelbuild/rules_go/pull/3329
    • feat(pkg-drv): allow setting custom aspect and kinds by @JamyDev in https://github.com/bazelbuild/rules_go/pull/3328
    • fix(packages-driver): allow defining additional aspects instead by @JamyDev in https://github.com/bazelbuild/rules_go/pull/3330
    • Add support for parsing Go development versions by @zakcutner in https://github.com/bazelbuild/rules_go/pull/3333
    • Match GOARCH ppc64 to @platforms//cpu:ppc as well. by @mahiuchun in https://github.com/bazelbuild/rules_go/pull/3336
    • bzlmod: Update Publish to BCR app config by @fmeum in https://github.com/bazelbuild/rules_go/pull/3337
    • gopackagesdriver: default to NotHandled:true for package queries by @ian-h-chamberlain in https://github.com/bazelbuild/rules_go/pull/3338
    • fix(packagesdrv): resolve third party go packages by @JamyDev in https://github.com/bazelbuild/rules_go/pull/3332
    • runfiles: port phst/runfiles to rules_go by @sluongng in https://github.com/bazelbuild/rules_go/pull/3205
    • Adding gc_linopts to command line flag by @linzhp in https://github.com/bazelbuild/rules_go/pull/3342
    • Move new runfiles library to //go/runfiles by @fmeum in https://github.com/bazelbuild/rules_go/pull/3341
    • Rename Path to Rlocation in runfiles library by @fmeum in https://github.com/bazelbuild/rules_go/pull/3346
    • Add 'gc_goopts' flag to command line to allow gc_goopts to propagate by @LWarrens in https://github.com/bazelbuild/rules_go/pull/3340

    New Contributors

    • @kmicklas made their first contribution in https://github.com/bazelbuild/rules_go/pull/3276
    • @adam-azarchs made their first contribution in https://github.com/bazelbuild/rules_go/pull/3313
    • @shs96c made their first contribution in https://github.com/bazelbuild/rules_go/pull/3320
    • @michaelarusso made their first contribution in https://github.com/bazelbuild/rules_go/pull/3327
    • @zakcutner made their first contribution in https://github.com/bazelbuild/rules_go/pull/3333
    • @mahiuchun made their first contribution in https://github.com/bazelbuild/rules_go/pull/3336
    • @LWarrens made their first contribution in https://github.com/bazelbuild/rules_go/pull/3340

    Full Changelog: https://github.com/bazelbuild/rules_go/compare/v0.35.0...v0.36.0

    WORKSPACE code

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "io_bazel_rules_go",
        sha256 = "ae013bf35bd23234d1dea46b079f1e05ba74ac0321423830119d3e787ec73483",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.36.0/rules_go-v0.36.0.zip",
            "https://github.com/bazelbuild/rules_go/releases/download/v0.36.0/rules_go-v0.36.0.zip",
        ],
    )
    
    load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
    
    go_rules_dependencies()
    
    go_register_toolchains(version = "1.19.3")
    
    Source code(tar.gz)
    Source code(zip)
    rules_go-v0.36.0.zip(1.19 MB)
  • v0.35.0(Sep 11, 2022)

    What's Changed

    • Add platform contraints for GOAMD64 by @fmeum in https://github.com/bazelbuild/rules_go/pull/3251
    • bzlmod: Fix after breaking change to go_deps.module by @fmeum in https://github.com/bazelbuild/rules_go/pull/3254
    • bzlmod: Check in io_bazel_rules_go -> rules_go patch for tests by @fmeum in https://github.com/bazelbuild/rules_go/pull/3262
    • Export support files needed for using Go's WebAssembly (WASM) output. by @ralimi in https://github.com/bazelbuild/rules_go/pull/3266
    • Add support for [email protected]_bazel_rules_go//go/toolchain:sdk_version flag. by @JamesMBartlett in https://github.com/bazelbuild/rules_go/pull/3260
    • Add support for go_binary to gopackagesdriver. by @DrewMonroe in https://github.com/bazelbuild/rules_go/pull/3271
    • migrating to rbe_preconfig by @aranguyen in https://github.com/bazelbuild/rules_go/pull/3272
    • Add go_cross_binary rule for cross-compilation. by @JamesMBartlett in https://github.com/bazelbuild/rules_go/pull/3261
    • delete duplicate return by @Abirdcfly in https://github.com/bazelbuild/rules_go/pull/3267
    • bzlmod: Use repo_name attribute on module instead of patches by @fmeum in https://github.com/bazelbuild/rules_go/pull/3279
    • Fix non_executable_test to work with @// labels by @Wyverald in https://github.com/bazelbuild/rules_go/pull/3281
    • bzlmod: Bump version to 0.34.0 by @fmeum in https://github.com/bazelbuild/rules_go/pull/3280
    • bzlmod: Add support for go_proto_library by @fmeum in https://github.com/bazelbuild/rules_go/pull/3283
    • Bumping minimal Bazel version to 5.1.0 by @linzhp in https://github.com/bazelbuild/rules_go/pull/3286
    • Getting architecture from JRE by @linzhp in https://github.com/bazelbuild/rules_go/pull/3282
    • Collect coverage for other languages by @fmeum in https://github.com/bazelbuild/rules_go/pull/3287

    New Contributors

    • @ralimi made their first contribution in https://github.com/bazelbuild/rules_go/pull/3266
    • @JamesMBartlett made their first contribution in https://github.com/bazelbuild/rules_go/pull/3260
    • @DrewMonroe made their first contribution in https://github.com/bazelbuild/rules_go/pull/3271
    • @aranguyen made their first contribution in https://github.com/bazelbuild/rules_go/pull/3272
    • @Abirdcfly made their first contribution in https://github.com/bazelbuild/rules_go/pull/3267

    Full Changelog: https://github.com/bazelbuild/rules_go/compare/v0.34.0...v0.35.0

    WORKSPACE code

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "io_bazel_rules_go",
        sha256 = "099a9fb96a376ccbbb7d291ed4ecbdfd42f6bc822ab77ae6f1b5cb9e914e94fa",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip",
            "https://github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip",
        ],
    )
    
    load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
    
    go_rules_dependencies()
    
    go_register_toolchains(version = "1.19.1")
    
    Source code(tar.gz)
    Source code(zip)
    rules_go-v0.35.0.zip(1.17 MB)
  • v0.34.0(Jul 19, 2022)

    What's Changed

    • releaser: fix scrubbing timestamp from patch files by @sluongng in https://github.com/bazelbuild/rules_go/pull/3180
    • Replace Starlark JSON parser with json.decode by @fmeum in https://github.com/bazelbuild/rules_go/pull/3184
    • gopackagesdriver: separates "s" files in pkg info by @iamricard in https://github.com/bazelbuild/rules_go/pull/3165
    • Refactor away references to @io_bazel_rules_go by @fmeum in https://github.com/bazelbuild/rules_go/pull/3185
    • Do not print to stderr if cgo linking succeeds after retry by @fmeum in https://github.com/bazelbuild/rules_go/pull/3187
    • Use param files with go-protoc by @fmeum in https://github.com/bazelbuild/rules_go/pull/3190
    • Don't include non-executable go_binary in dependent's runfiles by @fmeum in https://github.com/bazelbuild/rules_go/pull/3151
    • Link in native libraries of transitive dependencies in archive mode by @fmeum in https://github.com/bazelbuild/rules_go/pull/3186
    • runfiles: remove deprecated api by @sluongng in https://github.com/bazelbuild/rules_go/pull/3198
    • Fix failing open hermeticity test by @fmeum in https://github.com/bazelbuild/rules_go/pull/3206
    • Fix go_googleapis Gazelle patch by @nickgooding in https://github.com/bazelbuild/rules_go/pull/3193
    • Exclude unsupported C/C++ features by @fmeum in https://github.com/bazelbuild/rules_go/pull/3189
    • Allow gomock to take Bazel common attributes by @linzhp in https://github.com/bazelbuild/rules_go/pull/3207
    • Transition on edges not self by @illicitonion in https://github.com/bazelbuild/rules_go/pull/3116
    • Include go_transition_test in bazel aspect by @ian-h-chamberlain in https://github.com/bazelbuild/rules_go/pull/3160
    • Add an example for go_download_sdk.sdks by @fishy in https://github.com/bazelbuild/rules_go/pull/3139
    • tests: nogo over generated code by @sluongng in https://github.com/bazelbuild/rules_go/pull/3214
    • test nogo/coverage: test generated code by @sluongng in https://github.com/bazelbuild/rules_go/pull/3213
    • Remove references to go_transition_test by @linzhp in https://github.com/bazelbuild/rules_go/pull/3215
    • Basic bzlmod setup by @fmeum in https://github.com/bazelbuild/rules_go/pull/3047
    • Run BCR tests against Bazel 6.0.0-pre.20220608.2 by @fmeum in https://github.com/bazelbuild/rules_go/pull/3223
    • Use repo-relative labels in MODULE.bazel by @fmeum in https://github.com/bazelbuild/rules_go/pull/3226
    • upkeep: upgrade to go 1.18.3 and gazelle v0.26.0 by @sluongng in https://github.com/bazelbuild/rules_go/pull/3220
    • nogo: ignore generated source files by @sluongng in https://github.com/bazelbuild/rules_go/pull/3216
    • asm: Pass package path with -p by @fmeum in https://github.com/bazelbuild/rules_go/pull/3231
    • bzlmod: Add support for gomock by @fmeum in https://github.com/bazelbuild/rules_go/pull/3232
    • test cgo: ensure helper script works by @sluongng in https://github.com/bazelbuild/rules_go/pull/3236
    • Fix //tests/legacy/examples/cgo:cgo_lib_test on M1 Macs by @fmeum in https://github.com/bazelbuild/rules_go/pull/3237
    • gopackagesdriver: Descend into go_proto_compiler's deps by @fmeum in https://github.com/bazelbuild/rules_go/pull/3240
    • new_library: remove unused resolver by @sluongng in https://github.com/bazelbuild/rules_go/pull/3219
    • nogo: instantiate type info for generic types when running under Go >=1.18 by @farhaven in https://github.com/bazelbuild/rules_go/pull/3212

    New Contributors

    • @iamricard made their first contribution in https://github.com/bazelbuild/rules_go/pull/3165
    • @ian-h-chamberlain made their first contribution in https://github.com/bazelbuild/rules_go/pull/3160
    • @fishy made their first contribution in https://github.com/bazelbuild/rules_go/pull/3139
    • @farhaven made their first contribution in https://github.com/bazelbuild/rules_go/pull/3212

    Full Changelog: https://github.com/bazelbuild/rules_go/compare/v0.33.0...v0.34.0

    WORKSPACE code

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "io_bazel_rules_go",
        sha256 = "16e9fca53ed6bd4ff4ad76facc9b7b651a89db1689a2877d6fd7b82aa824e366",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.34.0/rules_go-v0.34.0.zip",
            "https://github.com/bazelbuild/rules_go/releases/download/v0.34.0/rules_go-v0.34.0.zip",
        ],
    )
    
    load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
    
    go_rules_dependencies()
    
    go_register_toolchains(version = "1.18.4")
    
    Source code(tar.gz)
    Source code(zip)
    rules_go-v0.34.0.zip(1.15 MB)
  • v0.33.0(Jun 6, 2022)

    Breaking changes

    Deprecations

    • The asm, compile, and pack action generators provided by go_context are deprecated and planned for removal in version v0.36.0. Please leave a comment on the tracking bug if archive and link are not suitable replacements for your use cases.

    Bug Fixes

    • @sluongng fixed a race condition that could cause non-sandboxed builds of go_test targets to fail (https://github.com/bazelbuild/rules_go/pull/3145)
    • @abhinav made //go:embed work with go_path (https://github.com/bazelbuild/rules_go/pull/3163)
    • @xytan0056 made gopackagesdriver work with Go 1.18 (https://github.com/bazelbuild/rules_go/pull/3157)
    • @nickgooding ensured that gomock can be used with any Gazelle naming convention (https://github.com/bazelbuild/rules_go/pull/3155)
    • go_library targets using CGo can now reference unresolved symbols (https://github.com/bazelbuild/rules_go/pull/3174)

    Thanks to all of the contributors!

    Compatibility

    The minimum required version of Bazel remains at 4.2.1.

    Updated dependencies

    • Updated org_golang_x_sys, org_golang_x_xerrors, org_golang_google_genproto, go_googleapis to their most recent commit as of 2022-06-05

    As always, you can use higher versions of rules_go's dependencies by declaring them in WORKSPACE before calling go_rules_dependencies. Lower versions may work but are not supported.

    WORKSPACE code

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "io_bazel_rules_go",
        sha256 = "685052b498b6ddfe562ca7a97736741d87916fe536623afb7da2824c0211c369",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.33.0/rules_go-v0.33.0.zip",
            "https://github.com/bazelbuild/rules_go/releases/download/v0.33.0/rules_go-v0.33.0.zip",
        ],
    )
    
    load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
    
    go_rules_dependencies()
    
    go_register_toolchains(version = "1.18.3")
    
    Source code(tar.gz)
    Source code(zip)
    rules_go-v0.33.0.zip(1.10 MB)
  • v0.32.0(May 11, 2022)

    This release brings many exciting changes

    New features

    • gomock rule is officially supported in rules_go (doc), replacing the original jmhodges/bazel_gomock repository. Thanks to @jmhodges for the original implementation.
    • rules_go now generates coverage reports in LCOV format by default (#3117), to be compatible with Bazel's --combined_report=lcov. To generate reports in the old go tool cover format, please use --//go/config:cover_format=go_cover. Thanks to @fmeum @abhinav
    • supporting windows/arm64 (#3072). Thanks to @nsait-linaro
    • nogo config can now takes analyzer_flags (#3082), thanks to @NavneethJayendran

    Bug fixes

    • Consider volatile and stable status files separately (#3079) Thanks to @siddharthab
    • Reducing duplicate information passed by go_pkg_info_aspect (#3111)
    • Fix include paths for CGo deps in external repositories (#3115) thanks to @fmeum
    • Revert change to use resolved shared lib links (#2907), thanks to @glukasiknuro
    • Fix lost x_defs on test execution (#3135), thanks to @bozaro
    • Let go_binary's executable bit depend on linkmode (#3143) thanks to @fmeum

    Deprecations

    go_embed_data and bindata will be deprecated in rules_go 0.35.0. Users are encourage to migrate to go:embed and embedsrcs.

    Other changes

    • Use output dir for empty packages to be hermetic (#3098), thanks to @joeljeske
    • Prevent downgrading platforms (#3076), thanks to @cpsauer
    • Doc improvements (#3100), thanks to @sluongng
    • Remove legacy proto code for Bazel < 0.21 (#3099), thanks to @cpsauer
    • Remove unused coverage code (#3118), thanks to @fmeum
    • Moving tests for go_embed_data and gomock to tests/extras (#3122)
    • Add command line copts/cxxopts to Cgo compile flags (#3126), thanks to @dchen496
    • Reset Go settings for protoc dependencies (#3005), thanks to @fmeum
    • Trim transitioned Go settings on non-Go dependencies (#3108), thanks to @fmeum

    Updated dependencies

    As always, you can use higher versions of rules_go's dependencies by declaring them in WORKSPACE before calling go_rules_dependencies. Lower versions may work but are not supported.

    • org_golang_google_protobuf updated to v1.28.0
    • org_golang_x_sys, org_golang_x_xerrors, org_golang_google_genproto and go_googleapis updated to master, as of 2022-05-09

    WORKSPACE code

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "io_bazel_rules_go",
        sha256 = "ab21448cef298740765f33a7f5acee0607203e4ea321219f2a4c85a6e0fb0a27",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.32.0/rules_go-v0.32.0.zip",
            "https://github.com/bazelbuild/rules_go/releases/download/v0.32.0/rules_go-v0.32.0.zip",
        ],
    )
    
    load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
    
    go_rules_dependencies()
    
    go_register_toolchains(version = "1.18.2")
    
    Source code(tar.gz)
    Source code(zip)
    rules_go-v0.32.0.zip(1.09 MB)
  • v0.31.0(Mar 21, 2022)

    This is a maintenance release to support Bazel 5.0. No new feature was added since last release.

    Changes

    • Add support for bazel 5.0.0 (#3068). Thanks to @moisesvega
    • Update documents (#3057, #3067). Thanks to @bcspragu and @jeongukjae
    • BUILD file clean up. Thanks to @JamyDev
    • symlink everything under lib/ when using local SDK (#3074). Thanks to @irfansharif

    Updated dependencies

    As always, you can use higher versions of rules_go's dependencies by declaring them in WORKSPACE before calling go_rules_dependencies. Lower versions may work but are not supported.

    • platforms updated to 0.0.5 as of 2022-03-14.
    • bazel_skylib updated to 1.2.1 as of 2022-03-14.
    • org_golang_x_tools updated to v0.1.9 as of 2022-03-14.
    • org_golang_x_sys updated to master as of 2022-03-14.
    • org_golang_google_genproto updated to main as of 2022-03-14.
    • go_googleapis updated to master as of 2022-03-14.

    Thanks @moisesvega for updating the dependencies and preparing the release notes.

    WORKSPACE code

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "io_bazel_rules_go",
        sha256 = "f2dcd210c7095febe54b804bb1cd3a58fe8435a909db2ec04e31542631cf715c",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.31.0/rules_go-v0.31.0.zip",
            "https://github.com/bazelbuild/rules_go/releases/download/v0.31.0/rules_go-v0.31.0.zip",
        ],
    )
    
    load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
    
    go_rules_dependencies()
    
    go_register_toolchains(version = "1.18")
    
    Source code(tar.gz)
    Source code(zip)
    rules_go-v0.31.0.zip(1.00 MB)
  • v0.30.0(Jan 24, 2022)

    Changes

    • Add first class support for GOOS=ios (#3013)

    • Always include debug symbols with -c dbg (#3029)

      Previously, debugging a go_test target was only possible with an explicit [email protected]_bazel_rules_go//go/config:debug.

    • go_test: Add env attribute (#3004)

      This allows setting environment variables before static initialisers run, and which reference expanded locations.

    • tests/core/cgo: do not assume test is being run from main repo (#2956)

    • reproducibility_test: explicitly build the go_sdk builder (#3026)

    • map bazel's --test_runner_fail_fast to go's -failfast (#3058)

    Bug Fixes

    • Emit correct header in CGo c-archive (#2874)
    • Append path into trimpath if option already exists (#2994)
    • Fixed issue with go_bazel_test rule on Windows (#3036)
    • Skipping linker flag for versioned dylib on Darwin (#2989)
    • Trim absolute paths in files generated by cgo (#3011)
    • builders/cover: register coverage without changing line numbers (#2993)
    • cover: use Z instead of underscore for variable name separator (#2995)
    • .bazelci/presubmit.yml: remove old flag (#3023)
    • builders/gentestmain: register correct cover mode in the coverage report file when enabling race mode (#3019)
    • -fsanitize-ignorelist should have an absolute path (#3001)
    • internal changes: #2942, #2987, #2988, #2992, #3000, #3035, #3038, #3046

    Thanks to all of the contributors

    Compatibility

    • Bazel 4.2.1 or higher is now required. The previous minimum version was 4.2.0.

    Updated dependencies

    As always, you can use higher versions of rules_go's dependencies by declaring them in WORKSPACE before calling go_rules_dependencies. Lower versions may work but are not supported.

    • org_golang_x_tools updated to v0.1.8 (#3031)
    • org_golang_x_sys updated to master as of 2022-01-24.
    • org_golang_google_genproto updated to master as of 2022-01-24.
    • go_googleapis updated to master as of 2022-01-24.

    WORKSPACE code

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "io_bazel_rules_go",
        sha256 = "d6b2513456fe2229811da7eb67a444be7785f5323c6708b38d851d2b51e54d83",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.30.0/rules_go-v0.30.0.zip",
            "https://github.com/bazelbuild/rules_go/releases/download/v0.30.0/rules_go-v0.30.0.zip",
        ],
    )
    
    load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
    
    go_rules_dependencies()
    
    go_register_toolchains(version = "1.17.6")
    
    Source code(tar.gz)
    Source code(zip)
    rules_go-v0.30.0.zip(1.00 MB)
  • v0.29.0(Oct 6, 2021)

    Changes

    • nogo analyzers may now depend on go_library rules (#2922).

      This is a major upgrade to nogo usability that enables the use of the popular staticcheck tool, via https://github.com/sluongng/staticcheck-codegen.

      This requires an update to Gazelle v0.24

      Many thanks to @thomas-wk

    • Editor / IDE integration (gopackagesdriver) now supports automatic target detection (#2932).

      No user input is required after the GOPACKAGESDRIVER setup. This effectively deprecates the following environment variables:

      • GOPACKAGESDRIVER_BAZEL_TARGETS
      • GOPACKAGESDRIVER_BAZEL_QUERY
      • GOPACKAGESDRIVER_BAZEL_TAG_FILTERS

      Many thanks to @steeve for his ongoing development of gopackagesdriver

    • The rules_cc dependency has been removed (#2950).

    • rules_go tool builds are now reproducible (#2952).

    • cgo-related bug fixes: #2930, #2925, #2947, #2926.

    Thanks to all of the contributors.

    Compatibility

    • Bazel 4.2.0 or higher is now required. The previous minimum version was 4.0.0.

    Updated dependencies

    As always, you can use higher versions of rules_go's dependencies by declaring them in WORKSPACE before calling go_rules_dependencies. Lower versions may work but are not supported.

    • bazel_skylib updated to v1.1.1
    • org_golang_x_tools updated to v0.1.7
    • org_golang_x_sys updated to master as of 2021-10-06.
    • org_golang_google_genproto updated to master as of 2021-10-06.
    • go_googleapis updated to master as of 2021-10-06.

    WORKSPACE code

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "io_bazel_rules_go",
        sha256 = "2b1641428dff9018f9e85c0384f03ec6c10660d935b750e3fa1492a281a53b0f",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.29.0/rules_go-v0.29.0.zip",
            "https://github.com/bazelbuild/rules_go/releases/download/v0.29.0/rules_go-v0.29.0.zip",
        ],
    )
    
    load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
    
    go_rules_dependencies()
    
    go_register_toolchains(version = "1.17.1")
    
    http_archive(
        name = "bazel_gazelle",
        sha256 = "de69a09dc70417580aabf20a28619bb3ef60d038470c7cf8442fafcf627c21cb",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz",
            "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz",
        ],
    )
    
    load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
    
    gazelle_dependencies()
    
    Source code(tar.gz)
    Source code(zip)
    rules_go-v0.29.0.zip(952.16 KB)
  • v0.28.0(Jul 7, 2021)

    Changes

    • Experimental editor / IDE integration added in the form of a gopackagesdriver tool that reports information about the Bazel workspace to gopls (or any other tool based on golang.org/x/tools/go/packages). See the Editor setup on the wiki for information and setup instructions. Huge thanks to @steeve for shipping this.
    • Target platform may be automatically inferred from --crosstool_top and --cpu for iOS and Android platforms that still require these flags. Again, thanks to @steeve.
    • go_proto_library no longer implicitly depends on APIv1 Well Known Type packages. Since protoc 3.14, the Well Known Types declare APIv2 package paths, which means generated code that imports them will import APIv2 packages, so the APIv1 dependencies are unnecessary.

    Compatibility

    • Bazel 4.0.0 (LTS) or higher is now required. The previous minimum version was 3.5.0.

    Updated dependencies

    As always, you can use higher versions of rules_go's dependencies by declaring them in WORKSPACE before calling go_rules_dependencies. Lower versions may work but are not supported.

    • org_golang_x_tools updated to v0.1.4
    • org_golang_x_sys updated to master as of 2021-06-30.
    • rules_cc updated to main as of 2021-06-30.
    • org_golang_google_protobuf updated to v1.27.1.
    • org_github_golang_protobuf updated to v1.5.2.
    • org_golang_google_genproto updated to master as of 2021-06-30.
    • go_googleapis updated to master as of 2021-06-30.

    WORKSPACE code

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "io_bazel_rules_go",
        sha256 = "8e968b5fcea1d2d64071872b12737bbb5514524ee5f0a4f54f5920266c261acb",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.28.0/rules_go-v0.28.0.zip",
            "https://github.com/bazelbuild/rules_go/releases/download/v0.28.0/rules_go-v0.28.0.zip",
        ],
    )
    
    load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
    
    go_rules_dependencies()
    
    go_register_toolchains(version = "1.16.5")
    
    Source code(tar.gz)
    Source code(zip)
    rules_go-v0.28.0.zip(923.96 KB)
  • v0.27.0(Mar 18, 2021)

    Updated dependencies

    This release updates golang.org/x/tools, which was mistakenly not updated in v0.26.0. Additionally, the latest version of golang.org/x/tools requires golang.org/x/sys/execabs, so that module is added as a new dependency.

    As always, you can use higher versions of rules_go's dependencies by declaring them in WORKSPACE before calling go_rules_dependencies. Lower versions may work but are not supported.

    • org_golang_x_tools is updated to v0.1.0.
    • org_golang_x_sys is added at master as of 2021-03-17.

    WORKSPACE code

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "io_bazel_rules_go",
        sha256 = "69de5c704a05ff37862f7e0f5534d4f479418afc21806c887db544a316f3cb6b",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.27.0/rules_go-v0.27.0.tar.gz",
            "https://github.com/bazelbuild/rules_go/releases/download/v0.27.0/rules_go-v0.27.0.tar.gz",
        ],
    )
    
    load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
    
    go_rules_dependencies()
    
    go_register_toolchains(version = "1.16.2")
    
    Source code(tar.gz)
    Source code(zip)
    rules_go-v0.27.0.tar.gz(618.85 KB)
  • v0.24.14(Mar 17, 2021)

    New Go versions

    Go 1.16.2, 1.16.1, 1.15.10, and 1.15.9 are now supported.

    WORKSPACE code

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "io_bazel_rules_go",
        sha256 = "e0015762cdeb5a2a9c48f96fb079c6a98e001d44ec23ad4fa2ca27208c5be4fb",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.14/rules_go-v0.24.14.tar.gz",
            "https://github.com/bazelbuild/rules_go/releases/download/v0.24.14/rules_go-v0.24.14.tar.gz",
        ],
    )
    
    load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
    
    go_rules_dependencies()
    
    go_register_toolchains()
    
    Source code(tar.gz)
    Source code(zip)
    rules_go-v0.24.14.tar.gz(512.53 KB)
  • v0.26.0(Mar 8, 2021)

    Changes

    • //go:embed directives are supported in Go 1.16. Patterns are matched against both static and generated files, including directory artifacts. Embeddable files must be listed in the new embedsrcs attribute. Gazelle v0.23.0 will generate these attributes automatically.
    • go_binary now provides CcInfo in the c-archive and c-shared link modes. This should let cc_library and other rules reference these targets through deps directly. Thanks @steeve.
    • TEST_TMPDIR is no longer set to TMPDIR in tests. Thanks @mikedanese.
    • Several small improvements in error and diagnostic output.

    Compatibility

    • Bazel 3.5.0 is now required. The previous minimum version was 3.4.0.

    Updated dependencies

    As always, you can use higher versions of rules_go's dependencies by declaring them in WORKSPACE before calling go_rules_dependencies. Lower versions may work but are not supported.

    • platforms is updated to 0.0.4.
    • rules_cc is updated to master as of 2021-03-05.
    • org_golang_x_tools is updated to master as of 2021-03-05.
    • org_golang_google_genproto is updated to master as of 2021-03-05.
    • go_googleapis is updated to master as of 2021-03-05.

    WORKSPACE code

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "io_bazel_rules_go",
        sha256 = "7c10271940c6bce577d51a075ae77728964db285dac0a46614a7934dc34303e6",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.26.0/rules_go-v0.26.0.tar.gz",
            "https://github.com/bazelbuild/rules_go/releases/download/v0.26.0/rules_go-v0.26.0.tar.gz",
        ],
    )
    
    load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
    
    go_rules_dependencies()
    
    go_register_toolchains(version = "1.16")
    
    Source code(tar.gz)
    Source code(zip)
    rules_go-v0.26.0.tar.gz(593.15 KB)
  • v0.24.13(Feb 16, 2021)

    New Go versions

    Go 1.16 is now supported.

    WORKSPACE code

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "io_bazel_rules_go",
        sha256 = "52d0a57ea12139d727883c2fef03597970b89f2cc2a05722c42d1d7d41ec065b",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.13/rules_go-v0.24.13.tar.gz",
            "https://github.com/bazelbuild/rules_go/releases/download/v0.24.13/rules_go-v0.24.13.tar.gz",
        ],
    )
    
    load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
    
    go_rules_dependencies()
    
    go_register_toolchains()
    
    Source code(tar.gz)
    Source code(zip)
    rules_go-v0.24.13.tar.gz(510.80 KB)
  • v0.24.12(Feb 5, 2021)

    New Go versions

    Go 1.15.8 and 1.14.15 are now supported.

    WORKSPACE code

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "io_bazel_rules_go",
        sha256 = "4d838e2d70b955ef9dd0d0648f673141df1bc1d7ecf5c2d621dcc163f47dd38a",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.12/rules_go-v0.24.12.tar.gz",
            "https://github.com/bazelbuild/rules_go/releases/download/v0.24.12/rules_go-v0.24.12.tar.gz",
        ],
    )
    
    load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
    
    go_rules_dependencies()
    
    go_register_toolchains()
    
    Source code(tar.gz)
    Source code(zip)
    rules_go-v0.24.12.tar.gz(510.44 KB)
  • v0.24.11(Jan 19, 2021)

    New Go versions

    Go 1.15.7 and 1.14.14 are now supported.

    WORKSPACE code

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "io_bazel_rules_go",
        sha256 = "dbf5a9ef855684f84cac2e7ae7886c5a001d4f66ae23f6904da0faaaef0d61fc",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.11/rules_go-v0.24.11.tar.gz",
            "https://github.com/bazelbuild/rules_go/releases/download/v0.24.11/rules_go-v0.24.11.tar.gz",
        ],
    )
    
    load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
    
    go_rules_dependencies()
    
    go_register_toolchains()
    
    Source code(tar.gz)
    Source code(zip)
    rules_go-v0.24.11.tar.gz(509.36 KB)
  • v0.25.1(Dec 23, 2020)

    Bug fixes

    • Fixed an issue in go_test with capturing XML output when changing directories.
    • Paths in error messages are now relativized. This should reduce noise from Bazel sandbox directories. (thanks @robfig)
    • go_local_sdk provides better error messages when Go is built for multiple platforms. (thanks @prattmic)
    • Multiple compatibility fixes for Go 1.16beta1.

    WORKSPACE code

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "io_bazel_rules_go",
        sha256 = "7904dbecbaffd068651916dce77ff3437679f9d20e1a7956bff43826e7645fcc",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.25.1/rules_go-v0.25.1.tar.gz",
            "https://github.com/bazelbuild/rules_go/releases/download/v0.25.1/rules_go-v0.25.1.tar.gz",
        ],
    )
    
    load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
    
    go_rules_dependencies()
    
    go_register_toolchains(version = "1.15.6")
    
    Source code(tar.gz)
    Source code(zip)
    rules_go-v0.25.1.tar.gz(552.65 KB)
  • v0.24.10(Dec 23, 2020)

    Bug fixes

    • Paths in error messages are now relativized. This should reduce noise from Bazel sandbox directories. (thanks @robfig)
    • go_local_sdk provides better error messages when Go is built for multiple platforms. (thanks @prattmic)
    • Multiple compatibility fixes for Go 1.16beta1.

    WORKSPACE code

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "io_bazel_rules_go",
        sha256 = "8e9434015ff8f3d6962cb8f016230ea7acc1ac402b760a8d66ff54dc11673ca6",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.10/rules_go-v0.24.10.tar.gz",
            "https://github.com/bazelbuild/rules_go/releases/download/v0.24.10/rules_go-v0.24.10.tar.gz",
        ],
    )
    
    load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
    
    go_rules_dependencies()
    
    go_register_toolchains()
    
    Source code(tar.gz)
    Source code(zip)
    rules_go-v0.24.10.tar.gz(508.39 KB)
  • v0.24.9(Dec 3, 2020)

    New Go versions

    Go 1.15.6 and 1.14.13 are now supported.

    WORKSPACE code

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "io_bazel_rules_go",
        sha256 = "81eff5df9077783b18e93d0c7ff990d8ad7a3b8b3ca5b785e1c483aacdb342d7",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.9/rules_go-v0.24.9.tar.gz",
            "https://github.com/bazelbuild/rules_go/releases/download/v0.24.9/rules_go-v0.24.9.tar.gz",
        ],
    )
    
    load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
    
    go_rules_dependencies()
    
    go_register_toolchains()
    
    Source code(tar.gz)
    Source code(zip)
    rules_go-v0.24.9.tar.gz(507.69 KB)
  • v0.25.0(Dec 2, 2020)

    Changes

    • go_download_sdk and go_register_toolchains can now download any version of Go from golang.org/dl without the need for hardcoded support in rules_go.
      • Consequently, the version parameter must be set to a string like "1.15.5" or to "host". This requires a change to WORKSPACE for most users. See go_register_toolchains for details.
      • go_download_sdk queries https://golang.org/dl in order to find SHA-256 of toolchains. Bazel won't cache downloaded files without these. If your build has limited network access, use version = "host" or set the sdks and urls attributes in go_download_sdk.
      • As a result of this change, rules_go will no longer need patch releases for new Go versions. The v0.24 branch will still be patched as long as it's supported.
    • Package conflicts are now errors rather than warnings. The linker already reports errors for most of these since Go 1.15.
    • rules_go now uses Bazel's modern C/C++ Starlark linker API.
    • go_path supports the include_transitive attribute, which controls whether transitively imported packages are included (thanks @steeve)
    • go_test changes to the test directory in an init function run before other package inits instead of in main (thanks @dragonsinth)
    • Several deprecated features were removed. See Deprecation schedule for information on removals.
      • go_rule wrapper.
      • go_archive_aspect and GoAspectProvider.
      • It is now an error when a go_binary or go_test depends on another go_binary or go_test.
      • --feature flags are no longer used for configuration. Use flags like [email protected]_bazel_rules_go//go/config:pure instead.

    Compatibility

    • Go 1.13 is no longer supported.
    • Bazel 3.4.0 is now required.
    • This release is expected to be compatible with Bazel 4.0.0. Earlier rules_go releases may not work due to incompatible changes in the C/C++ APIs.

    Updated dependencies

    As always you can use higher versions of rules_go's dependencies by declaring them in WORKSPACE before calling go_rules_dependencies. Lower versions may work but are not supported.

    • platforms is updated to 0.0.1.
    • rules_cc is updated to master as of 2020-12-01.
    • bazel_skylib is updated to 1.0.3.
    • org_golang_x_tools is updated to master as of 2020-12-01.
    • com_github_golang_protobuf is updated to v1.4.3.
    • org_golang_google_genproto is updated to master as of 2020-12-01.
    • go_googleapis is updated to master as of 2020-12-01.

    WORKSPACE code

    NOTE: The code below has changed. In go_register_toolchains, version must be set to a string like "1.15.5" or to "host" unless a Go toolchain is declared earlier.

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "io_bazel_rules_go",
        sha256 = "6f111c57fd50baf5b8ee9d63024874dd2a014b069426156c55adbf6d3d22cb7b",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.25.0/rules_go-v0.25.0.tar.gz",
            "https://github.com/bazelbuild/rules_go/releases/download/v0.25.0/rules_go-v0.25.0.tar.gz",
        ],
    )
    
    load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
    
    go_rules_dependencies()
    
    go_register_toolchains(version = "1.15.5")
    
    Source code(tar.gz)
    Source code(zip)
    rules_go-v0.25.0.tar.gz(551.47 KB)
  • v0.24.8(Dec 2, 2020)

    Bug fixes

    • go_test no longer requires TestMain to call os.Exit (thanks @rabbbit)
    • @io_bazel_rules_go//proto/wkt:field_mask_go_proto, source_context_go_proto, and type_go_proto are now wrappers around the pre-generated sources in google.golang.org/protobuf. This should eliminate linker conflicts.
    • go_proto_library now declares implicit dependencies on both APIv1 and APIv2 packages. This may increase build time (both sets of packages will be compiled) but is needed for compatibility with protobuf 3.14.0. go_proto_library needs both sets of packages, since we don't know which version of protobuf is used at analysis time.
    • go_binary and go_test now force internal linking in pure mode, since a C/C++ toolchain is not available. This should produce better error messages on platforms that don't support internal linking.

    WORKSPACE code

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "io_bazel_rules_go",
        sha256 = "75c97f089190833ee58872238c98394267d35c32baabf42aac0827102b62af6b",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.8/rules_go-v0.24.8.tar.gz",
            "https://github.com/bazelbuild/rules_go/releases/download/v0.24.8/rules_go-v0.24.8.tar.gz",
        ],
    )
    
    load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
    
    go_rules_dependencies()
    
    go_register_toolchains()
    
    Source code(tar.gz)
    Source code(zip)
    rules_go-v0.24.8.tar.gz(506.55 KB)
  • v0.24.7(Nov 12, 2020)

    New Go versions

    Go 1.15.5 and 1.14.12 are now supported.

    WORKSPACE code

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "io_bazel_rules_go",
        sha256 = "207fad3e6689135c5d8713e5a17ba9d1290238f47b9ba545b63d9303406209c6",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.7/rules_go-v0.24.7.tar.gz",
            "https://github.com/bazelbuild/rules_go/releases/download/v0.24.7/rules_go-v0.24.7.tar.gz",
        ],
    )
    
    load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
    
    go_rules_dependencies()
    
    go_register_toolchains()
    
    Source code(tar.gz)
    Source code(zip)
    rules_go-v0.24.7.tar.gz(505.66 KB)
  • v0.23.15(Nov 12, 2020)

    New Go versions

    Go 1.15.5 and 1.14.12 are now supported.

    WORKSPACE code

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "io_bazel_rules_go",
        sha256 = "e3f4c9aef825c2ac023d0d78f74f7bc22b4b918a329b2d1b888b2978ff5ac154",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.23.15/rules_go-v0.23.15.tar.gz",
            "https://github.com/bazelbuild/rules_go/releases/download/v0.23.15/rules_go-v0.23.15.tar.gz",
        ],
    )
    
    load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
    
    go_rules_dependencies()
    
    go_register_toolchains()
    
    Source code(tar.gz)
    Source code(zip)
    rules_go-v0.23.15.tar.gz(476.88 KB)
  • v0.24.6(Nov 9, 2020)

    New Go versions

    Go 1.15.4 and 1.14.11 are now supported.

    WORKSPACE code

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "io_bazel_rules_go",
        sha256 = "b4433651f57560237681cb9caa969106aba614f5b1e66fefa5834c42b8013b42",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.6/rules_go-v0.24.6.tar.gz",
            "https://github.com/bazelbuild/rules_go/releases/download/v0.24.6/rules_go-v0.24.6.tar.gz",
        ],
    )
    
    load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
    
    go_rules_dependencies()
    
    go_register_toolchains()
    
    Source code(tar.gz)
    Source code(zip)
    rules_go-v0.24.6.tar.gz(504.34 KB)
  • v0.23.14(Nov 9, 2020)

    New Go versions

    Go 1.15.4 and 1.14.11 are now supported.

    WORKSPACE code

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "io_bazel_rules_go",
        sha256 = "e19e73c40511461a2f45ad45ccbfeff15184264a2169bbb10b5a7f4f0b578b90",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.23.14/rules_go-v0.23.14.tar.gz",
            "https://github.com/bazelbuild/rules_go/releases/download/v0.23.14/rules_go-v0.23.14.tar.gz",
        ],
    )
    
    load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
    
    go_rules_dependencies()
    
    go_register_toolchains()
    
    Source code(tar.gz)
    Source code(zip)
    rules_go-v0.23.14.tar.gz(475.79 KB)
  • v0.24.5(Oct 26, 2020)

    Bug fixes

    • Fixed an issue with include paths in cgo libraries in external repositories that was exposed in Bazel 3.7.0.
    • Subcommand errors are now less verbose.

    WORKSPACE code

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "io_bazel_rules_go",
        sha256 = "d1ffd055969c8f8d431e2d439813e42326961d0942bdf734d2c95dc30c369566",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.5/rules_go-v0.24.5.tar.gz",
            "https://github.com/bazelbuild/rules_go/releases/download/v0.24.5/rules_go-v0.24.5.tar.gz",
        ],
    )
    
    load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
    
    go_rules_dependencies()
    
    go_register_toolchains()
    
    Source code(tar.gz)
    Source code(zip)
    rules_go-v0.24.5.tar.gz(503.07 KB)
  • v0.23.13(Oct 26, 2020)

    Bug fixes

    • Fixed an issue with include paths in cgo libraries in external repositories that was exposed in Bazel 3.7.0.
    • Subcommand errors are now less verbose.

    WORKSPACE code

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "io_bazel_rules_go",
        sha256 = "efc724310fa2568db33ce3cc9b8fdbe1d0b554435d41e64b7f96d68933a5ca15",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.23.13/rules_go-v0.23.13.tar.gz",
            "https://github.com/bazelbuild/rules_go/releases/download/v0.23.13/rules_go-v0.23.13.tar.gz",
        ],
    )
    
    load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
    
    go_rules_dependencies()
    
    go_register_toolchains()
    
    Source code(tar.gz)
    Source code(zip)
    rules_go-v0.23.13.tar.gz(474.72 KB)
  • v0.24.4(Oct 15, 2020)

    New Go versions

    Go 1.15.3 and 1.14.10 are now supported.

    WORKSPACE code

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "io_bazel_rules_go",
        sha256 = "ac03931e56c3b229c145f1a8b2a2ad3e8d8f1af57e43ef28a26123362a1e3c7e",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.4/rules_go-v0.24.4.tar.gz",
            "https://github.com/bazelbuild/rules_go/releases/download/v0.24.4/rules_go-v0.24.4.tar.gz",
        ],
    )
    
    load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
    
    go_rules_dependencies()
    
    go_register_toolchains()
    
    Source code(tar.gz)
    Source code(zip)
    rules_go-v0.24.4.tar.gz(502.97 KB)
  • v0.23.12(Oct 15, 2020)

    New Go versions

    Go 1.15.3 and 1.14.10 are now supported.

    WORKSPACE code

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "io_bazel_rules_go",
        sha256 = "df76f2a947aef03979ea0b6b9551d55ecc1821e4097f86a8422fdeac80b9ecd4",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.23.12/rules_go-v0.23.12.tar.gz",
            "https://github.com/bazelbuild/rules_go/releases/download/v0.23.12/rules_go-v0.23.12.tar.gz",
        ],
    )
    
    load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
    
    go_rules_dependencies()
    
    go_register_toolchains()
    
    Source code(tar.gz)
    Source code(zip)
    rules_go-v0.23.12.tar.gz(474.66 KB)
  • v0.24.3(Sep 22, 2020)

    Bug fixes

    • The GoPath action uses absolute paths to mitigate path length limits on Windows (thanks @Xjs).
    • The file lib/time/zoneinfo.zip is now exported from downloaded Go distributions (thanks @andrewtar).
    • Multiline package conflict error messages are correctly passed to the builder when Bazel param files are used.
    • Compiler errors are redirected from stdout to stderr.

    WORKSPACE code

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "io_bazel_rules_go",
        sha256 = "b725e6497741d7fc2d55fcc29a276627d10e43fa5d0bb692692890ae30d98d00",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.3/rules_go-v0.24.3.tar.gz",
            "https://github.com/bazelbuild/rules_go/releases/download/v0.24.3/rules_go-v0.24.3.tar.gz",
        ],
    )
    
    load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
    
    go_rules_dependencies()
    
    go_register_toolchains()
    
    Source code(tar.gz)
    Source code(zip)
    rules_go-v0.24.3.tar.gz(501.99 KB)
  • v0.23.11(Sep 22, 2020)

    Bug fixes

    • coverdata is now imported correctly in files with import comments (thanks @linzhp).
    • cdeps are correctly passed to the linker when a split test's packages are recompiled.
    • The GoPath action uses absolute paths to mitigate path length limits on Windows (thanks @Xjs).
    • The file lib/time/zoneinfo.zip is now exported from downloaded Go distributions (thanks @andrewtar).
    • Multiline package conflict error messages are correctly passed to the builder when Bazel param files are used.
    • Compiler errors are redirected from stdout to stderr.

    WORKSPACE code

    load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
    
    http_archive(
        name = "io_bazel_rules_go",
        sha256 = "bca583b49e4705ffa51d793ee4e2403e1eaab4d31222af8d950ef7cfe731ea33",
        urls = [
            "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.23.11/rules_go-v0.23.11.tar.gz",
            "https://github.com/bazelbuild/rules_go/releases/download/v0.23.11/rules_go-v0.23.11.tar.gz",
        ],
    )
    
    load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
    
    go_rules_dependencies()
    
    go_register_toolchains()
    
    Source code(tar.gz)
    Source code(zip)
    rules_go-v0.23.11.tar.gz(473.68 KB)
Owner
Bazel
Bazel organization
Bazel
Generate types and service clients from protobuf definitions annotated with http rules.

protoc-gen-typescript-http Generates Typescript types and service clients from protobuf definitions annotated with http rules. The generated types fol

Einride 32 Nov 22, 2022
The rest api that can manage the iptables rules of the remote host

fiewall-api firewall api是基于firewalld来远程管理iptables规则的rest-api,无需部署agent Features 指定一个主机ip,让这个主机上的iptables增加一个规则 处理单个IP或CIDR范围(xx.xx.xx.xx/mask,mac,inte

seal 0 Mar 24, 2022
Read k8S-source-code notes, help quickly understand the K8S-code organization rules

K8S源码阅读笔记 以下笔记针对 kubernetes V1.23.1(截至2022年01月01日最新版本),并不保证对其它版本的有效性 一、架构图 二、阅读前准备 由于kubernetes项目巧妙的设计和代码高度的封装性,建议在阅读代码前,尽可能的进行以下内容的准备: 1. 编程知识配备 编程语准

kubernetes-based edge-cloud solution 0 Feb 16, 2022
KeeneticRouteToVpn is simple app updating Keenetic Router rules for some hosts to go through VPN interface.

KeeneticRouteToVpn KeeneticRouteToVpn is simple app updating Keenetic Router rules for some hosts to go through VPN interface. It has defaults values

Vasilii Blazhnov 8 Oct 8, 2022
Squzy - is a high-performance open-source monitoring, incident and alert system written in Golang with Bazel and love.

Squzy - opensource monitoring, incident and alerting system About Squzy - is a high-performance open-source monitoring and alerting system written in

Squzy 470 Nov 22, 2022
Baize - A minimum implement of bazel remote execution

BAIZE Baize, mythical creatures in ancient Chinese mythology, who can speak with

DashJay 4 Jul 24, 2022
A Golang library to manipulate strings according to the word parsing rules of the UNIX Bourne shell.

shellwords A Golang library to manipulate strings according to the word parsing rules of the UNIX Bourne shell. Installation go get github.com/Wing924

Wei He 18 Sep 27, 2022
A natural language date/time parser with pluggable rules

when when is a natural language date/time parser with pluggable rules and merge strategies Examples tonight at 11:10 pm at Friday afternoon the deadli

Oleg Lebedev 1.2k Nov 11, 2022
A rest application to update firewalld rules on a linux server

Firewalld-rest A REST application to dynamically update firewalld rules on a linux server. Firewalld is a firewall management tool for Linux operating

Prashant Gupta 325 Nov 25, 2022
⚙️ Convert HTML to Markdown. Even works with entire websites and can be extended through rules.

html-to-markdown Convert HTML into Markdown with Go. It is using an HTML Parser to avoid the use of regexp as much as possible. That should prevent so

Johannes Kaufmann 429 Nov 27, 2022
Validate Golang request data with simple rules. Highly inspired by Laravel's request validation.

Validate golang request data with simple rules. Highly inspired by Laravel's request validation. Installation Install the package using $ go get githu

Saddam H 1.2k Nov 23, 2022
An idiomatic Go (golang) validation package. Supports configurable and extensible validation rules (validators) using normal language constructs instead of error-prone struct tags.

ozzo-validation Description ozzo-validation is a Go package that provides configurable and extensible data validation capabilities. It has the followi

Ozzo Framework 3k Nov 28, 2022
Application for HTTP benchmarking via different rules and configs

Go Benchmark App The efficiency and speed of application - our goal and the basic idea. Application for HTTP-benchmarking via different rules and conf

Evgeny Ukhanov 25 Dec 1, 2022
Generate types and service clients from protobuf definitions annotated with http rules.

protoc-gen-typescript-http Generates Typescript types and service clients from protobuf definitions annotated with http rules. The generated types fol

Einride 32 Nov 22, 2022
A natural language date/time parser with pluggable rules

when when is a natural language date/time parser with pluggable rules and merge strategies Examples tonight at 11:10 pm at Friday afternoon the deadli

Oleg Lebedev 1.2k Nov 11, 2022
Generate Prometheus rules for your SLOs

prometheus-slo Generates Prometheus rules for alerting on SLOs. Based on https://developers.soundcloud.com/blog/alerting-on-slos. Usage Build and Run

Ganesh Vernekar 17 Oct 20, 2021
A parser generator where rules defined as go structs and code generation is optional

A parser generator where rules defined as go structs and code generation is optional. The concepts are introduced in the simple example below.

Arnaud Delobelle 6 Jul 1, 2022
go-linters How to grow Go code as a bonsai: the style, the rules, the linters

How to grow Go code as a bonsai: the style, the rules, the linters (Definition 2021 Hackaton) Build go build -buildmode=plugin plugin/plugin.go Run go

Mercuryo.io 2 Nov 9, 2022
An easy to use relay for cftools webhook events piped to Discord when filter rules match.

CFTools Relay CFTools Relay is an easy-to-use, still in development, tool that allows you to subscribe to CFTools Cloud Webhook events and forward the

Florian 3 Nov 22, 2022