Skip to content
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

Adds support for proto3opt #22

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

gburek-fastly
Copy link
Contributor

This pr attempts to detect optional fields by using
field.Oneof.Desc.IsSynthetic() to distinguish between oneof fields and optional fields, which are implemented as oneof between a type and nil. We also rely on nil checking pointers for the marshall and unmarshalling.

This code was able to successfully generate reflectionless opentelemetry-proto-go definitions which use optional fields: gburek-fastly/opentelemetry-proto-go#1

Closes #21

Attempts to detect optional fields by using
`field.Oneof.Desc.IsSynthetic()` and relies on nil checking pointers for
the marshall and unmarshalling
@paralin
Copy link
Member

paralin commented Oct 28, 2024

Thanks for this! Elegant solution

I'll just test it against my codebase real quick and then will merge this evening. Thanks again.

@paralin paralin merged commit 4ff7f98 into aperturerobotics:master Oct 29, 2024
7 checks passed
@paralin
Copy link
Member

paralin commented Oct 29, 2024

Great work, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Allow generation of messages with optional fields
2 participants