jmattheis / goverter

Generate type-safe Go converters by simply defining an interface
https://goverter.jmattheis.de/
MIT License
496 stars 46 forks source link

Is there a way to convert to code generate by protobuf oneof #54

Closed gpoulin closed 1 year ago

gpoulin commented 1 year ago

Have you read the project readme?

Describe your question I'm trying to convert a pure Go struct to a struct generated using protobuf that include oneof. The generated code for oneof create an un-exported interface ref with multiple struct that implement the interface. I didn't find a way to use goverter to convert such a field. I tried using a custom Mapping Method but since the type is not exported by protobuf, it's not possible to define such method. One workaround to work with oneof is to create a type alias in the same module as the generated code. However, goverter match type based on there name ref so an alias wouldn't work. Is there a way that I missed to convert a struct that contains such a oneof?

jmattheis commented 1 year ago

Could you provide a minimal example which goverter cannot convert (input, output struct & goverter converter interface)?