golang / protobuf

Go support for Google's protocol buffers
BSD 3-Clause "New" or "Revised" License
9.74k stars 1.58k forks source link

protocmp: how to ignore field in one of? #1506

Open HartBlanc opened 1 year ago

HartBlanc commented 1 year ago

I have a message M with a Oneof field O, one of the values O can take Ox has a field F.

I want to ignore F in a comparison.

I'm unable to address the field without either getting a panic or a compilation error using either protocmp.IgnoreFields or protocmp.IgnoreOneofs.

How can I ignore F in a cmp.Equal comparison?

stapelberg commented 1 year ago

Could you please supply a runnable program to illustrate the issue? Thanks.

puellanivis commented 1 year ago

Also, what panics / compilation errors are you seeing? We can help significantly faster and better when we know exactly what issue you’re facing.