Use reflect.TypeOf() to get the concrete type of a oneOf interface value. 

Package-Private Interface:

- Exposing it could be useful for function composition but risks violating 
the protobuf contract.

- Workarounds like type switches or custom interfaces can achieve similar 
goals without breaking encapsulation.


On Wednesday, July 2, 2025 at 9:28:45 AM UTC-7 X Dev wrote:

> Hi guys
>
>
> Please, in `golang` having a oneOf field how at runtime to enumerate the 
> types that fits the target interface (e.g. reflection)?
>
>
> And a sibling question why actually the interface generated for the oneOf 
> purpose 
> is a package private. It is really logically not to expose the interface 
> content it self to restrict the types as described in a proto.
> Still the interface it self would be useful for e.g. to define a function 
> that composes related result.
>
>
> Thank you
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/protobuf/d83a6555-6b0f-45ab-89c3-8227622f1f4en%40googlegroups.com.

Reply via email to