I have 2 proto compiled under different go packages but when I register them in a a server and run it, I get :
panic: proto: file "common.proto" is already registered
previously from: "github.com/soft/test-platform.go/common"
currently from: "github.com/soft/proto-asterix/asterix"
Here is common.proto in test-platform repository (in /api folder) :
syntax = "proto3";
package soft.testplatform.common; // here I do defint a UNIQUE package name !
option java_multiple_files = true;
option go_package = "github.com/soft/test-platform.go/common"; // Here I do define a unique go package name !
message MyMessage{
string commandId = 1;
}
As you can see, the package definition for go_package and package do not collide with package from github.com/soft/proto-asterix/asterix. Only the .proto filenames are similar (common.proto).
I generate go files with protoc an protoc-gen-go plugin using the following command :
protoc \
--proto_path=../test-platform/api/ \
--go_out=./common --go_opt=paths=source_relative \
../test-platform/api/common.proto
As per documentation here https://developers.google.com/protocol-buffers/docs/reference/go/faq#fix-namespace-conflict the package and filename should be appended to check for a registration conflict but it does not seem to be the case here.
Has anyone encountered such behavior ? Do I miss something obvious to resolve this package name collision ?
Here is what I tried :
- Adding/removing
packageinstruction tocommon.protofile - Change protoc command to use an absolute (and not relative)
proto_path
Protoc version : libprotoc 3.15.7 Protoc go plugin version : protoc-gen-go v1.26.0