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

Fix generic comparisons on protobuf messages #93

Open
wants to merge 1 commit into
base: master
from

Conversation

@dsnet
Copy link

dsnet commented Nov 6, 2019

Generated protobuf messages contain internal data structures
that general purpose comparison functions (e.g., reflect.DeepEqual,
pretty.Compare, etc) do not properly compare. It is already the case
today that these functions may report a difference when two messages
are actually semantically equivalent.

Fix all usages by either calling proto.Equal directly if
the top-level types are themselves proto.Message, or by calling
cmp.Equal with the cmp.Comparer(proto.Equal) option specified.
This option teaches cmp to use proto.Equal anytime it encounters
proto.Message types.

Generated protobuf messages contain internal data structures
that general purpose comparison functions (e.g., reflect.DeepEqual,
pretty.Compare, etc) do not properly compare. It is already the case
today that these functions may report a difference when two messages
are actually semantically equivalent.

Fix all usages by either calling proto.Equal directly if
the top-level types are themselves proto.Message, or by calling
cmp.Equal with the cmp.Comparer(proto.Equal) option specified.
This option teaches cmp to use proto.Equal anytime it encounters
proto.Message types.
@googlebot googlebot added the cla: yes label Nov 6, 2019
@ola-rozenfeld ola-rozenfeld self-requested a review Nov 8, 2019
@ola-rozenfeld

This comment has been minimized.

Copy link
Collaborator

ola-rozenfeld commented Nov 8, 2019

I think you need to run gazelle to fix your dependencies, then this will work. Thank you!

@ola-rozenfeld

This comment has been minimized.

Copy link
Collaborator

ola-rozenfeld commented Nov 9, 2019

Do a bazel run //:gazelle from the repo root directory. Then, bazel test ... to make sure everything works. If you don't have bazel installed, you can get it here: https://github.com/bazelbuild/bazel/releases/tag/1.1.0

Thank you for cleaning this up!

@dsnet

This comment has been minimized.

Copy link
Author

dsnet commented Nov 10, 2019

Would you be willing to make this change for me? I need to make these trivial changes to a number of projects and I don't have the bandwidth to setup the right developer environment for each one.

@ola-rozenfeld

This comment has been minimized.

Copy link
Collaborator

ola-rozenfeld commented Nov 11, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.