Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

option go_package in proto files #18341

Open
semyon-dev opened this issue Jul 17, 2024 · 4 comments
Open

option go_package in proto files #18341

semyon-dev opened this issue Jul 17, 2024 · 4 comments
Labels
priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done. type/feature

Comments

@semyon-dev
Copy link

What would you like to be added?

There has been a commit in the main branch for at least 10 months that adds option go_package: https://github.com/etcd-io/etcd/blob/main/server/storage/wal/walpb/record.proto#L7

But the latest version (v3.5.14) does not have this option, please add this option (or commit) to the next version.

Why is this needed?

I am using two dependencies (one of them is etcd) that have the same proto files - record.proto, and because of this there is a conflict. To resolve this conflict, option go_package is needed.

Now I have to do this: os.Setenv("GOLANG_PROTOBUF_REGISTRATION_CONFLICT", "ignore") or I will get a panic:

panic: proto: file "record.proto" is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict


goroutine 1 [running]:
google.golang.org/protobuf/reflect/protoregistry.init.func1({0x7ff6c0cc8e90?, 0x7ff6c111ba40?}, {0x7ff6c1716f60, 0xc00031d2b0})
	C:/Users/user/go/src/github.com/pkg/mod/google.golang.org/[email protected]/reflect/protoregistry/registry.go:56 +0x1ec
google.golang.org/protobuf/reflect/protoregistry.(*Files).RegisterFile(0xc000008ed0, {0x7ff6c1746458, 0xc000331880})
	C:/Users/user/go/src/github.com/pkg/mod/google.golang.org/[email protected]/reflect/protoregistry/registry.go:130 +0xbc3
google.golang.org/protobuf/internal/filedesc.Builder.Build({{0x0, 0x0}, {0xc00032f600, 0x11d, 0x200}, 0x0, 0x2, 0x0, 0x0, {0x7ff6c171e9b0, ...}, ...})
	C:/Users/user/go/src/github.com/pkg/mod/google.golang.org/[email protected]/internal/filedesc/build.go:112 +0x1d6
github.com/golang/protobuf/proto.RegisterFile({0x7ff6c115751a, 0xc}, {0x7ff6c0c48940, 0xea, 0xea})
	C:/Users/user/go/src/github.com/pkg/mod/github.com/golang/[email protected]/proto/registry.go:48 +0x148
go.etcd.io/etcd/server/v3/wal/walpb.init.1()
	C:/Users/user/go/src/github.com/pkg/mod/go.etcd.io/etcd/server/[email protected]/wal/walpb/record.pb.go:119 +0x34

Process finished with the exit code 2
@ahrtr
Copy link
Member

ahrtr commented Jul 19, 2024

But the latest version (v3.5.14) does not have this option, please add this option (or commit) to the next version.

Have you confirmed that it's working if you depend on etcd main branch?

@semyon-dev
Copy link
Author

But the latest version (v3.5.14) does not have this option, please add this option (or commit) to the next version.

Have you confirmed that it's working if you depend on etcd main branch?

I'm sorry, the problem remained on the main branch, but I don't understand why

@ahrtr
Copy link
Member

ahrtr commented Jul 22, 2024

the problem remained on the main branch, but I don't understand why

Thanks for the feedback. It means that it won't hep to backport the option go_package change to 3.5.

I suggest you to raise this issue/question in protobuf community. https://github.com/protocolbuffers/protobuf-go

@ahrtr
Copy link
Member

ahrtr commented Jul 22, 2024

Based on https://protobuf.dev/reference/go/faq/#namespace-conflict, it's a best practice to specify a package name in .proto file. So let's keep this ticket open until the root cause is clear.

@jmhbnz jmhbnz added the priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done. label Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done. type/feature
Development

No branches or pull requests

3 participants