feat: Add tools/list-return-structs - #4478
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>
|
@gmlewis So, are we going to remove |
I haven't decided and haven't heard any great arguments for one versus the other. So I guess the answer right now is "No". |
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.