grpc / grpc-go

The Go language implementation of gRPC. HTTP/2 based RPC
https://grpc.io
Apache License 2.0
21.09k stars 4.39k forks source link

Unwanted namespacing warning/ or error #6853

Closed mamaart closed 11 months ago

mamaart commented 11 months ago

What version of gRPC are you using?

1.59.0

What version of Go are you using (go version)?

1.21.4

What operating system (Linux, Windows, …) and version?

Linux 6.6.4-arch1-1

What did you do?

I have multiple protos defined in a git repo and the generated code is in this repo as well and I use it to import the functionality into the server and clients.

├── events_service │   ├── admin.proto │   ├── golang │   │   ├── admin │   │   │   ├── admin_grpc.pb.go │   │   │   └── admin.pb.go │   │   ├── generate.sh │   │   ├── go.mod │   │   ├── go.sum │   │   ├── shared │   │   │   └── shared.pb.go │   │   └── user │   │   ├── user_grpc.pb.go │   │   └── user.pb.go │   ├── shared.proto │   └── user.proto ├── mailbox_service │   ├── admin.proto │   ├── golang │   │   ├── admin │   │   │   ├── admin_grpc.pb.go │   │   │   └── admin.pb.go │   │   ├── generate.sh │   │   ├── go.mod │   │   └── user │   │   ├── user_grpc.pb.go │   │   └── user.pb.go │   └── user.proto ├── member_service │   ├── admin.proto │   ├── golang │   │   ├── admin │   │   │   ├── admin_grpc.pb.go │   │   │   └── admin.pb.go │   │   ├── generate.sh │   │   ├── go.mod │   │   ├── registration │   │   │   ├── registration_grpc.pb.go │   │   │   └── registration.pb.go │   │   ├── shared │   │   │   └── shared.pb.go │   │   └── statistics │   │   ├── statistics_grpc.pb.go │   │   └── statistics.pb.go │   ├── registration.proto │   ├── shared.proto │   └── statistics.proto └── README.md

They are not related to eachother.

Inside some of them have a protofile called shared (its only used inside the domain and not shared with the others.)

When I have a client application that use all of the protos I get a panic, but I managed to reduce it to a warning after reading the FAQ in the error message.

I have even namespaced the package name in the proto - for instance:

syntax = "proto3";

package eventsservice.shared;

option go_package = "github.com/dk-slack/protos/events_service/golang/shared";

What did you expect to see?

Nothing, no warning and no errors.

What did you see instead?

After running this:

❯ GOLANG_PROTOBUF_REGISTRATION_CONFLICT=warn go run ./cmd
WARNING: proto: file "shared.proto" is already registered
    previously from: "github.com/dk-slack/protos/events_service/golang/shared"
    currently from:  "github.com/dk-slack/protos/member_service/golang/shared"
See https://protobuf.dev/reference/go/faq#namespace-conflict

WARNING: proto: file "admin.proto" is already registered
    previously from: "github.com/dk-slack/protos/events_service/golang/admin"
    currently from:  "github.com/dk-slack/protos/member_service/golang/admin"
See https://protobuf.dev/reference/go/faq#namespace-conflict
easwars commented 11 months ago

This feels like a protobuf issue and not a grpc issue. Please open an issue with the protobuf repository. Thanks.