Closed idy closed 6 years ago
Do you mean the go_proto_library
or go_library
rule generated for that proto has the wrong import path? How are you importing that repository? rules_go imports it automatically in go_rules_dependencies
. The build file for that library has the correct import path.
When import google/protobuf/field_mask.proto
in a proto file, gazelle add @com_github_golang_protobuf//ptypes/field_mask:go_default_library
to deps
of go_proto_library
.
Gazelle(internal/resolve/resolve.go#L245) classify all proto with a prefix google/protobuf
as well-known proto, but the .pb.go
file of field_mask
is not in the same place with other wkts, e.g. any
, empty
, etc.
File: test.proto
syntax = "proto3";
import "google/protobuf/field_mask.proto";
message Resource {}
message UpdateResourceMessage {
Resource resource = 1;
google.protobuf.FieldMask update_mask = 2;
}
Auto generated build file: BUILD.bazel
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
proto_library(
name = "test_proto",
srcs = ["test.proto"],
visibility = ["//visibility:public"],
deps = ["@com_google_protobuf//:field_mask_proto"],
)
go_proto_library(
name = "test_go_proto",
importpath = "xrc/experimental/users/yan/api",
proto = ":test_proto",
visibility = ["//visibility:public"],
deps = ["@com_github_golang_protobuf//ptypes/field_mask:go_default_library"],
)
go_library(
name = "go_default_library",
embed = [":test_go_proto"],
importpath = "xrc/experimental/users/yan/api",
visibility = ["//visibility:public"],
)
Actually, Gazelle should not be adding dependencies on well known types at all in go_proto_library
. This has been the responsibility of go_proto_compiler
for a while, and I never came back and removed those from Gazelle. #143 will remove these.
That said, field_mask is not one of the standard dependencies added by the default compilers. bazelbuild/rules_go#1358 will add this in a standard place though.
I'm going to close this issue since both #143 and bazelbuild/rules_go#1358 have been merged. I expect to do a major release at the beginning of April that will include both these changes. Please re-open if anything else should be fixed before then.
field_mask has the well-known prefix, but its import path is not following the well-known pattern.
Correct import path should be
google.golang.org/genproto/protobuf/field_mask
, but gazelle generatesgithub.com/golang/protobuf/ptypes/field_mask
.