Hi Guys!
I've been working on a transient problem in the 
github.com/kubernetes/client-go library that keeps us from using an updated 
version of github.com/googleapis/gnostic. The tl;dr on the problem (which 
serves as background for my question) is that the tests make heavy use of 
`reflect.DeepEqual` and therefore encounter problems when `XXX_` fields are 
inserted into messages, a known issue. I discovered `cmp`, `protocmp`, 
`protoreflect` and dived pretty deep into the works on that, but haven't 
figured out how to accomplish the simple task I want. It seems like 
something others would encounter as well, so I'm asking here.

My goal is to strip messages of the `XXX_` fields (preferably after the 
`Unmarshalling` step) in order to do comparisons without those fields 
throwing off `cmp`. I've seen some discussion around using 
UnmarshallOptions to do some transformations, but this would require all 
component libraries to be using APIv2 (and implement 
`protoreflect.MessageReflect`), and not the backwards compatibility of 
APIv1. What is the idiomatic way to accomplish this?

Unmarshalling step: 
https://github.com/timfallmk/kubernetes/blob/tf-gnostic-experiment/staging/src/k8s.io/client-go/discovery/discovery_client.go#L437

Test that needs replacing (and fails): 
https://github.com/timfallmk/kubernetes/blob/d8e619b5db5cfe57e9a77c25e126412c5881ca0f/staging/src/k8s.io/client-go/discovery/discovery_client_test.go#L524-L525

This might serve as a good example to document in the `protocmp` package? I 
imagine a lot of people are going to be running into this issue or 
something like it.

-Tim

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/dd56522d-3869-4454-bc39-9886947ed306%40googlegroups.com.

Reply via email to