version: v1
plugins:
- plugin: buf.build/protocolbuffers/go
out: api
opt:
- paths=source_relative
- plugin: buf.build/connectrpc/go
out: api
opt:
- paths=source_relative
WORKSPACE
# Declares that this directory is the root of a Bazel workspace.
# See https://docs.bazel.build/versions/main/build-ref.html#workspace
workspace(
# How this workspace would be referenced with absolute labels from another workspace
name = "driver-service",
)
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
## GO
http_archive(
name = "io_bazel_rules_go",
sha256 = "d6ab6b57e48c09523e93050f13698f708428cfd5e619252e369d377af6597707",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.43.0/rules_go-v0.43.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.43.0/rules_go-v0.43.0.zip",
],
)
http_archive(
name = "bazel_gazelle",
sha256 = "b7387f72efb59f876e4daae42f1d3912d0d45563eac7cb23d1de0b094ab588cf",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.34.0/bazel-gazelle-v0.34.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.34.0/bazel-gazelle-v0.34.0.tar.gz",
],
)
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
############################################################
# Define your own dependencies here using go_repository.
# Else, dependencies declared by rules_go/gazelle will be used.
# The first declaration of an external repository "wins".
############################################################
load("//:go_deps.bzl", "go_dependencies")
# gazelle:repository_macro go_deps.bzl%go_dependencies
go_dependencies()
go_rules_dependencies()
go_register_toolchains(version = "1.20.5")
gazelle_dependencies()
gazelle_dependencies(go_repository_default_config = "//:WORKSPACE")
# ## Buf.build
http_archive(
name = "rules_buf",
sha256 = "523a4e06f0746661e092d083757263a249fedca535bd6dd819a8c50de074731a",
strip_prefix = "rules_buf-0.1.1",
urls = [
"https://github.com/bufbuild/rules_buf/archive/refs/tags/v0.1.1.zip",
],
)
load("@rules_buf//buf:repositories.bzl", "rules_buf_dependencies", "rules_buf_toolchains")
rules_buf_dependencies()
rules_buf_toolchains(version = "v1.28.1")
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
load("//:buf_deps.bzl", "buf_deps")
# gazelle:repository_macro buf_deps.bzl%buf_deps
buf_deps()
rules_proto_dependencies()
rules_proto_toolchains()
load("@rules_buf//gazelle/buf:repositories.bzl", "gazelle_buf_dependencies")
gazelle_buf_dependencies()
MODULE.bazel
bazel_dep(name = "rules_oci", version = "1.4.3")
oci = use_extension("@rules_oci//oci:extensions.bzl", "oci")
oci.pull(
name = "distroless",
digest = "sha256:6706c73aae2afaa8201d63cc3dda48753c09bcd6c300762251065c0f7e602b25",
image = "gcr.io/distroless/static",
platforms = [
"linux/amd64",
"linux/arm64/v8",
],
)
# For each oci.pull call, repeat the "name" here to expose them as dependencies.
use_repo(oci, "distroless")
BUILD
load("@bazel_gazelle//:def.bzl", "DEFAULT_LANGUAGES", "gazelle", "gazelle_binary")
gazelle_binary(
name = "gazelle-buf",
languages = DEFAULT_LANGUAGES + [
# Loads the Buf extension
"@rules_buf//gazelle/buf:buf",
# NOTE: This needs to be loaded after the proto language
],
)
# gazelle:prefix github.com/ride-app/driver-service
# gazelle:build_file_name BUILD.bazel
# gazelle:exclude infra
# gazelle:proto disable_global
gazelle(
name = "gazelle",
gazelle = ":gazelle-buf",
)
gazelle(
name = "gazelle-update-repos-go",
args = [
"-from_file=go.mod",
"-to_macro=go_deps.bzl%go_dependencies",
"-prune",
],
command = "update-repos",
gazelle = ":gazelle-buf",
)
gazelle(
name = "gazelle-update-repos-buf",
args = [
# This can also be `buf.yaml` and `buf.lock`.
"--from_file=buf.work.yaml",
# This is optional but recommended, if absent gazelle
# will add the rules directly to WORKSPACE
"-to_macro=buf_deps.bzl%buf_deps",
# Deletes outdated repo rules
"-prune",
],
command = "update-repos",
gazelle = ":gazelle-buf",
)
Finally run
bazel build //...
Environment (please complete the following information):
Describe the bug
When using connect-go with bazel, bazel throws the following error:
But when the code is inspected manually it looks perfect
To Reproduce
Copy the files in buf module ride/driver
then generate files using
buf generate
buf.gen.yaml
WORKSPACE
MODULE.bazel
BUILD
Finally run
Environment (please complete the following information):
connect-go
: v1.13.0go version
: go version go1.21.5 darwin/arm64go.mod
:buf --version
: 1.28.1