-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add method that wraps oneof messages in their wrapper struct #727
Comments
Given:
How does your proposal work? |
That is very unfortunate. I was not aware that was a possibility. |
This is unrelated to #708 as that issue is regarding hiding internal details of oneof, and has nothing to do with the public API. It seems that your use-case is more in line with the purposes of the Any message type given that you have a field in the "master" message can be only oneof a bunch of different messages. As @puellanivis noted, oneofs do not seem to be what you want since:
Closing as infeasible. We can't add this functionality as it assumes some specific semantic of oneofs that isn't true. |
Thanks for the link to the Any message, that seems perfect. |
Glad you’re able to find a forward path. 👍 |
Is your feature request related to a problem? Please describe.
oneof fields are annoying and clunky to use at the moment. In particular wrapping the actual type of the message with the wrapper struct is clunky.
Describe the solution you'd like
I want to write a function like this:
(I have a "master" message that contains all of the messages I can send to the client as a oneof field and this function is supposed to write one of those oneofed messages)
What's missing is the
mypbpackage.WrapMyOneOfField
method. I'd like that to be auto generated. It would take aproto.Message
and return the interface implemented by all of theoneof
wrapper structs (this interface would now have to become exported).Describe alternatives you've considered
Manually writing this function. I'm doing this for now but it'd be nice if it was autogenerated. The other alternative is to manually wrap oneof messages every time which is annoying.
Somewhat related #708
The text was updated successfully, but these errors were encountered: