I would say having multiple files with the same path is asking for trouble and shouldn't be considered valid. On the other hand, I wouldn't be surprised if there is code out there that attempts to tolerate this situation anyway, maybe to accommodate legacy code. I'm not sure what this particular Go code you linked to is trying to do, though.
On Tue, Nov 8, 2022 at 3:58 AM Bingo Kang <[email protected]> wrote: > As the code says, it is not permitted for multiple files to have the same > file path. > But as the comment says, it is permitted for multiple files to have the > same file path. > I'm so confused...... : ( > > 在2022年11月8日星期二 UTC+8 19:56:19<Bingo Kang> 写道: > >> In google.golang.org/protobuf v1.28.1, >> reflect/protoregistry/registry.go, comment says: >> >> // It is permitted for multiple files to have the same file path. >> func (r *Files) RegisterFile(file protoreflect.FileDescriptor) error { >> ... >> } >> >> But as the code says: >> >> path := file.Path() >> if prev := r.filesByPath[path]; len(prev) > 0 { >> r.checkGenProtoConflict(path) >> err := errors.New("file %q is already registered", file.Path()) >> err = amendErrorWithCaller(err, prev[0], file) >> if !(r == GlobalFiles && ignoreConflict(file, err)) { >> return err >> } >> } >> >> It seems that the code and the comment is not the same. >> Please, anyone knows why? >> > -- > 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 on the web visit > https://groups.google.com/d/msgid/protobuf/5edee73c-ec5e-46c5-83da-1fda47b9540bn%40googlegroups.com > <https://groups.google.com/d/msgid/protobuf/5edee73c-ec5e-46c5-83da-1fda47b9540bn%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 on the web visit https://groups.google.com/d/msgid/protobuf/CADqAXr5qP_Ji7fzG%2BwVGUq1ixW2Ro1GR8VdyMtmVUmL2ZzjokA%40mail.gmail.com.
