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

release/v2.2007: pb: avoid protobuf warning due to common filename (#1519) #1731

Merged
merged 1 commit into from
Jul 21, 2021

Conversation

NamanJain8
Copy link
Contributor

@NamanJain8 NamanJain8 commented Jul 20, 2021

If a Go program imports both badger (v1) and badger/v2, a warning will
be produced at init time:

WARNING: proto: file "pb.proto" is already registered
A future release will panic on registration conflicts. See:
https://developers.google.com/protocol-buffers/docs/reference/go/faq#namespace-conflict

The problem is the "pb.proto" filename; it's registered globally, which
makes it very likely to cause conflicts with other protobuf-generated
packages in a Go binary.

Coincidentally, this is a problem with badger's pb package in the v1 module,
since that too uses the name "pb.proto". Instead, call the file
"badgerpb2.proto", which should be unique enough, and it's also the name
we use for the Protobuf package.

Finally, update gen.sh to work out of the box via just "bash gen.sh"
without needing extra tweaks, thanks to the "paths=source_relative"
option. It forces output files to be produced next to the input files,
which is what we want.

(cherry picked from commit 3e6a4b7)


This change is Reviewable

If a Go program imports both badger (v1) and badger/v2, a warning will
be produced at init time:

	WARNING: proto: file "pb.proto" is already registered
	A future release will panic on registration conflicts. See:
	https://developers.google.com/protocol-buffers/docs/reference/go/faq#namespace-conflict

The problem is the "pb.proto" filename; it's registered globally, which
makes it very likely to cause conflicts with other protobuf-generated
packages in a Go binary.

Coincidentally, this is a problem with badger's pb package in the v1 module,
since that too uses the name "pb.proto". Instead, call the file
"badgerpb2.proto", which should be unique enough, and it's also the name
we use for the Protobuf package.

Finally, update gen.sh to work out of the box via just "bash gen.sh"
without needing extra tweaks, thanks to the "paths=source_relative"
option. It forces output files to be produced next to the input files,
which is what we want.

(cherry picked from commit 3e6a4b7)
@NamanJain8 NamanJain8 requested a review from manishrjain as a code owner July 20, 2021 16:31
@NamanJain8 NamanJain8 changed the title pb: avoid protobuf warning due to common filename (#1519) release/v2.2007: pb: avoid protobuf warning due to common filename (#1519) Jul 20, 2021
@NamanJain8 NamanJain8 merged commit 73c1ce3 into release/v2.2007 Jul 21, 2021
@NamanJain8 NamanJain8 deleted the naman/proto-conflict branch July 21, 2021 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants