Repository navigation
Add nil-safe getters for optional Go fields - #41
Closed
THEjacob1000 wants to merge 1 commit into
Closed
THEjacob1000 wants to merge 1 commit into
THEjacob1000 wants to merge 1 commit into
Conversation
THEjacob1000
force-pushed
the
feat/go-codegen-optional-getters
branch
2 times, most recently
from
October 7, 2026 01:55
d7f59e1 to
60191b4
Compare
THEjacob1000
force-pushed
the
feat/go-codegen-optional-getters
branch
from
October 7, 2026 01:58
60191b4 to
bc1bb74
Compare
Member
|
I don't see how this solves anything related to the parent PR |
Contributor
Author
|
it doesn't fix anything, the pointers do. getters are just qol so callers that don't care about presence can do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Internal change only
[LOKE-XXXX]
Generated Go clients now have nil-safe getters for optional fields that #39 turns into pointers. Inspired by Go protobuf scalar getters: pointers track presence; getters return values or defaults. Callers that don't need to distinguish absence from a zero value can use
Get<Field>(), including on a nil receiver, instead of repeating nil checks.Getters are also generated for object definitions reached through refs. Names that collide with existing fields or getters gain an underscore suffix, preserving the existing field names and keeping the generated client compilable.
This stacks on #39. Consumers can adopt getters where zero-value fallback is appropriate and keep checking the pointer where presence matters; the JSON format stays unchanged.
Related PRs
Screenshots / Videos
I have:
all the above must be ticked