From 26b9cb15320bbc942952083a2b9b8b428b9c67b7 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Fri, 15 Aug 2025 17:28:04 +0800 Subject: [PATCH] Revert "go_grpc_compiler: default to go_grpc_v2 (#2071)" This reverts commit e425d46f735e6ccb8c83237f47b4bf338d317a84. Moving to @io_bazel_rules_go//proto:go_grpc_v2 is not a drop-in replacement and fails if the proto library has both messages and services defined. Fixes #2170 --- README.rst | 6 +++--- cmd/gazelle/integration_test.go | 4 ++-- language/go/config.go | 2 +- language/go/constants.go | 2 +- language/go/fix_test.go | 2 +- language/go/testdata/proto_file_mode/abc/BUILD.want | 2 +- language/go/testdata/service/BUILD.want | 2 +- .../go/testdata/service_gogo_subdir_reset/sub/BUILD.want | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.rst b/README.rst index 0f99d952c..155878f23 100644 --- a/README.rst +++ b/README.rst @@ -538,7 +538,7 @@ The following flags are accepted: | If `all` or `true`, Gazelle indexes all directories in the repository, even when recursion is disabled. | | This makes dependency resolution simple but can be slow for large repositories. | +-------------------------------------------------------------------+------------------------------------------+ -| :flag:`-go_grpc_compiler` | ``@io_bazel_rules_go//proto:go_grpc_v2`` | +| :flag:`-go_grpc_compiler` | ``@io_bazel_rules_go//proto:go_grpc`` | +-------------------------------------------------------------------+------------------------------------------+ | The protocol buffers compiler to use for building go bindings for gRPC. May be repeated. | | | @@ -856,7 +856,7 @@ The following directives are recognized: | * ``file``: A distinct ``go_test`` rule will be generated for each ``_test.go`` file in the | | package directory. | +---------------------------------------------------+------------------------------------------+ -| :direc:`# gazelle:go_grpc_compilers` | ``@io_bazel_rules_go//proto:go_grpc_v2`` | +| :direc:`# gazelle:go_grpc_compilers` | ``@io_bazel_rules_go//proto:go_grpc_`` | +---------------------------------------------------+------------------------------------------+ | The protocol buffers compiler(s) to use for building go bindings for gRPC. | | Multiple compilers, separated by commas, may be specified. | @@ -1278,7 +1278,7 @@ attributes with ``embed`` attributes. **Migrate gRPC compilers (fix and update):** Gazelle converts ``go_grpc_library`` rules to ``go_proto_library`` rules with -``compilers = ["@io_bazel_rules_go//proto:go_grpc_v2"]``. +``compilers = ["@io_bazel_rules_go//proto:go_grpc"]``. **Flatten srcs (fix and update):** Gazelle converts ``srcs`` attributes that use OS and architecture-specific ``select`` expressions to flat lists. diff --git a/cmd/gazelle/integration_test.go b/cmd/gazelle/integration_test.go index 3c0ef4eb4..6cc4b0855 100644 --- a/cmd/gazelle/integration_test.go +++ b/cmd/gazelle/integration_test.go @@ -771,7 +771,7 @@ proto_library( go_proto_library( name = "repo_go_proto", - compilers = ["@io_bazel_rules_go//proto:go_grpc_v2"], + compilers = ["@io_bazel_rules_go//proto:go_grpc"], importpath = "example.com/repo", proto = ":repo_proto", visibility = ["//visibility:public"], @@ -2033,7 +2033,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library") go_proto_library( name = "service_go_proto", - compilers = ["@io_bazel_rules_go//proto:go_grpc_v2"], + compilers = ["@io_bazel_rules_go//proto:go_grpc"], importpath = "example.com/repo/service", proto = ":service_proto", visibility = ["//visibility:public"], diff --git a/language/go/config.go b/language/go/config.go index 17457210b..c474bcfc5 100644 --- a/language/go/config.go +++ b/language/go/config.go @@ -156,7 +156,7 @@ const ( var ( defaultGoProtoCompilers = []string{"@io_bazel_rules_go//proto:go_proto"} - defaultGoGrpcCompilers = []string{"@io_bazel_rules_go//proto:go_grpc_v2"} + defaultGoGrpcCompilers = []string{"@io_bazel_rules_go//proto:go_grpc"} ) func (m testMode) String() string { diff --git a/language/go/constants.go b/language/go/constants.go index dfb75b466..0affc48a9 100644 --- a/language/go/constants.go +++ b/language/go/constants.go @@ -33,7 +33,7 @@ const ( // grpcCompilerLabel is the label for the gRPC compiler plugin, used in the // "compilers" attribute of go_proto_library rules. - grpcCompilerLabel = "@io_bazel_rules_go//proto:go_grpc_v2" + grpcCompilerLabel = "@io_bazel_rules_go//proto:go_grpc" // goProtoSuffix is the suffix applied to the labels of all generated // go_proto_library targets. diff --git a/language/go/fix_test.go b/language/go/fix_test.go index fd5e8687a..d811102ac 100644 --- a/language/go/fix_test.go +++ b/language/go/fix_test.go @@ -581,7 +581,7 @@ proto_library( go_proto_library( name = "foo_go_proto", - compilers = ["@io_bazel_rules_go//proto:go_grpc_v2"], + compilers = ["@io_bazel_rules_go//proto:go_grpc"], importpath = "example.com/repo", proto = ":foo_proto", visibility = ["//visibility:public"], diff --git a/language/go/testdata/proto_file_mode/abc/BUILD.want b/language/go/testdata/proto_file_mode/abc/BUILD.want index 24243d1e8..8d6588bc2 100644 --- a/language/go/testdata/proto_file_mode/abc/BUILD.want +++ b/language/go/testdata/proto_file_mode/abc/BUILD.want @@ -21,7 +21,7 @@ go_proto_library( "abc/a.proto", "xyz/x.proto", ], - compilers = ["@io_bazel_rules_go//proto:go_grpc_v2"], + compilers = ["@io_bazel_rules_go//proto:go_grpc"], importpath = "example.com/repo/proto_file_mode/abc", protos = [ ":a_proto", diff --git a/language/go/testdata/service/BUILD.want b/language/go/testdata/service/BUILD.want index 17f24b17f..abdda81e6 100644 --- a/language/go/testdata/service/BUILD.want +++ b/language/go/testdata/service/BUILD.want @@ -18,7 +18,7 @@ go_proto_library( "google/protobuf/any.proto", "service/sub/sub.proto", ], - compilers = ["@io_bazel_rules_go//proto:go_grpc_v2"], + compilers = ["@io_bazel_rules_go//proto:go_grpc"], importpath = "example.com/repo/service", proto = ":service_proto", visibility = ["//visibility:public"], diff --git a/language/go/testdata/service_gogo_subdir_reset/sub/BUILD.want b/language/go/testdata/service_gogo_subdir_reset/sub/BUILD.want index 7ece1724e..bdf1ccd81 100644 --- a/language/go/testdata/service_gogo_subdir_reset/sub/BUILD.want +++ b/language/go/testdata/service_gogo_subdir_reset/sub/BUILD.want @@ -12,7 +12,7 @@ proto_library( go_proto_library( name = "protos_gogo_go_proto", _gazelle_imports = [], - compilers = ["@io_bazel_rules_go//proto:go_grpc_v2"], + compilers = ["@io_bazel_rules_go//proto:go_grpc"], importpath = "example.com/repo/protos_gogo", proto = ":protos_gogo_proto", visibility = ["//visibility:public"],