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

go: preserve nil structs on decode #87

Merged
merged 1 commit into from
Sep 12, 2024
Merged

go: preserve nil structs on decode #87

merged 1 commit into from
Sep 12, 2024

Conversation

lgfa29
Copy link
Contributor

@lgfa29 lgfa29 commented Sep 12, 2024

When decoding a struct with struct fields, the generated decode() method would replace the nil fields with an empty new struct. Since nil fields are stored in the original message with zero bytes (0x00), we can check for it before attempting to decode the field into an intialized zero value.

When decoding a struct with struct fields, the generated `decode()`
method would replace the `nil` fields with an empty new struct. Since
`nil` fields are stored in the original message with zero bytes
(`0x00`), we can check for it before attempting to decode the field into
an intialized zero value.

Signed-off-by: Luiz Aoqui <[email protected]>
Copy link
Contributor

@SuperManifolds SuperManifolds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lgfa29 lgfa29 merged commit 0191de2 into main Sep 12, 2024
9 checks passed
@lgfa29 lgfa29 deleted the preserve-nil branch September 12, 2024 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants