Is your feature request related to a problem? Please describe.
I need to compare two protobuf messages in tests. I use cmp + protocmp for that. A message has a repeated field but for that certain type (repeated message) ordering doesn't matter.
Describe the solution you'd like
I'd like to have a protocmp.SortSlices() option for protocmp.Transform() so that slices are sorted before they are transformed. There are probably other options that are applicable.
Describe alternatives you've considered
cmpopts.SortSlices() doesn't work because the slice/repeated field is a field, it's not top level. So, protocmp transforms it into protocmp.Message and hence cmpopts.SortSlices() doesn't work on it when used with the actual field element type.
Additional context
I'm going to use cmpopts.SortSlices() with filtering + protocmp.Message as a workaround but this is quite a hassle.
Is your feature request related to a problem? Please describe.
I need to compare two protobuf messages in tests. I use cmp + protocmp for that. A message has a repeated field but for that certain type (repeated message) ordering doesn't matter.
Describe the solution you'd like
I'd like to have a
protocmp.SortSlices()
option forprotocmp.Transform()
so that slices are sorted before they are transformed. There are probably other options that are applicable.Describe alternatives you've considered
cmpopts.SortSlices()
doesn't work because the slice/repeated field is a field, it's not top level. So, protocmp transforms it intoprotocmp.Message
and hencecmpopts.SortSlices()
doesn't work on it when used with the actual field element type.Additional context
I'm going to use
cmpopts.SortSlices()
with filtering +protocmp.Message
as a workaround but this is quite a hassle.