-
Notifications
You must be signed in to change notification settings - Fork 22
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
Make omitempty structs pointers. #75
Conversation
This is needed so that unset JSON values get initialized to `nil` in Go instead of the zero struct. The zero struct is indistinguishable from an explicitly set struct with zero values, and will get serialized despite "omitempty". `nil` on the other hand will be dropped, as expected. Fixes google#72.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would like a second pair of eyes on my question.
Thanks for taking a look Suzy. What would it take to get this merged? |
Would you mind pulling in the latest commits from tip? There is a fix to the CI and I would like to see the tests run against this change. Thank you! I'll finish reviewing the code as well. |
@rehmsen Looks like just a couple of test cases need to be fixed up! They appear to all be intentional differences in behavior from this change that just need to be reflected in the tests located in cmd/mockserver/server_test.go. |
Weird, it took a while to run. I was not able to run them locally completely (failed to install staticcheck I think), but the part that ran I fixed. Will it automatically rerun to check if they are all fixed now? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Thank you for the PR!
var loadedSourcesRequestStruct = LoadedSourcesRequest{ | ||
Request: *newRequest(31, "loadedSources"), | ||
Arguments: LoadedSourcesArguments{}, | ||
Arguments: nil, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this field can be omitted completely.
This is needed so that unset JSON values get initialized to
nil
in Go instead of the zero struct. The zero struct is indistinguishable from an explicitly set struct with zero values, and will get serialized despite "omitempty".nil
on the other hand will be dropped, as expected.Fixes #72.