feat: Add tools/list-return-structs - #4478
Merged
Merged
Conversation
Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4478 +/- ##
=======================================
Coverage 98.51% 98.51%
=======================================
Files 195 195
Lines 17691 17691
=======================================
Hits 17429 17429
Misses 262 262 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com>
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.
This tool directly answers the questions raised here:
#4460 (comment)
This tool shows that there are 615 structs in this repo that are used strictly as return values and are never included as input parameters to
optsorbodyvalues, and are therefore only unmarshaled in the non-test Go source files.Out of these 615 return-only structs, 487 of them include at least one field that uses the
json"omitempty" or "omitzero" option.As correctly pointed out by @stevehipwell, the
omitemptyoromitzeroin these 487 structs are unnecessary and can be removed.Although, as @Tens1des pointed out, the
omitemptyis nice to have there when usingtestJSONMarshalso that anullis not provided in the output.So I'm a bit torn on this issue and am leaning toward keeping the
omitempty/omitzerofor unmarshal-only structs.