I believe the issue is more inherent to protobuf in general and not a Go specific thing; basically if you have a file that does `import "x.proto"` that needs to be able to be resolved uniquely. Note that it should not require the _file names_ themselves to be globally unique, the problem arises when you invoke protoc with something like this:
protoc -Iproject1 project1/foo.proto protoc -Iproject2 project2/foo.proto Which results in the two files being represented as their (necessarily globally unique name) of just "foo.proto". If you instead invoke proto without the -I, there would be no conflict (because the two files will have their canonical file names as "project1/foo.proto" and "project2/foo.proto"): protoc project1/foo.proto protoc project2/foo.proto You may find more discussion about this (including some details which are Go specific) here: https://github.com/golang/protobuf/issues/1122 On Wed, Dec 4, 2024 at 11:18 AM Jan Pfeifer <[email protected]> wrote: > hi all, > > Today I bumped into the conflicting file name registration runtime error > below. > > ``` > panic: proto: file "sentencepiece_model.proto" is already registered > previously from: "github.com/eliben/go-sentencepiece/internal/model > <http://127.0.0.1:8889/eliben/go-sentencepiece/internal/model>" currently > from: "github.com > /gomlx/go-huggingface/tokenizers/sentencepiece/private/protos > <http://127.0.0.1:8889/gomlx/go-huggingface/tokenizers/sentencepiece/private/protos>" > See https://protobuf.dev/reference/go/faq#namespace-conflict > ``` > > The two libraries I'm using define the protos under different proto > `package` names, as well as different `option go_package` paths -- so in > principle, I understand, the protos they define should be unrelated and > have no conflict. > > For the record, `syntax = "proto2"` is defined in both proto files. > > Just the last part of the file name ("sentencepiece_model.proto") are the > same, they are in different paths. > > I own one of these libraries, so I could change the file name to something > like: > > "sentencepiece_model_<unique_hash>.proto" > > And that works as expected -- but it is a sad solution :). > > Am I misunderstanding the error ? Any suggestions on how to prevent such > conflicts ? > > Many thanks in advance. > > -- > You received this message because you are subscribed to the Google Groups > "Protocol Buffers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion visit > https://groups.google.com/d/msgid/protobuf/9ab9719e-dda1-4809-ac61-89b41a4a9ae7n%40googlegroups.com > <https://groups.google.com/d/msgid/protobuf/9ab9719e-dda1-4809-ac61-89b41a4a9ae7n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/protobuf/CAKRmVH-RKhWQ%2Br3RHK-82qmeE%3DK77vJCOnyOtiSOVL1%2Bwxr3ig%40mail.gmail.com.
