I recently hit a problem with my
go-github library where I'm unable to set values to their zero value, since they are defined with omitempty and they get dropped when marshalling the JSON (full GitHub issue
here). The obvious answer seems to be to use pointers for my struct fields, especially since that's what goprotobuf uses. My two questions are:
1) In my (certainly non-exhaustive) perusal of various go libraries, this pattern does not seem to be very well adopted. Clearly, some of that may be cases where there isn't a need to explicitly set a field to it's zero-value. But certainly, I would have expected to see this more. Am I just not looking in the right places, and this is more common than I think it is?
2) If it is a more common pattern, would it make sense to promote proto.String() and friends to a more general location? What are other libraries doing for this (creating pointers to primitive types)? Are they redefining those helper functions, importing goprotobuf just for those helpers, not using helpers at all?