xx
.md

go_protobuf

go_protobuf installs google.golang.org/protobuf/cmd/protoc-gen-go with the selected managed Go SDK and returns a typed generator for protobuf_generate.

Arguments

ArgumentRequiredDescription
versionYesExact protoc-gen-go semantic version without a leading v, such as "1.36.6".
depsNoDependencies activated before go install, in list order. Defaults to [].

The helper installs google.golang.org/protobuf/cmd/protoc-gen-go@v<version> using the same isolated command directory and managed environment as go_install. Selecting the returned generator activates that installation automatically before protoc.

Example

load("@[email protected]", "go_protobuf")
load("@[email protected]", "protobuf_generate")

protobuf_generate(
    sources=["proto/service.proto"],
    generator=go_protobuf("1.36.6"),
    output="generated/go",
    proto_paths=["proto"],
    options=["paths=source_relative"],
)