Skip to content

feat: Add tools/list-return-structs - #4478

Merged
gmlewis merged 2 commits into
google:masterfrom
gmlewis:add-list-return-structs
Aug 21, 2026
Merged

feat: Add tools/list-return-structs#4478
gmlewis merged 2 commits into
google:masterfrom
gmlewis:add-list-return-structs

Conversation

@gmlewis

@gmlewis gmlewis commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

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 opts or body values, 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 omitempty or omitzero in these 487 structs are unnecessary and can be removed.

Although, as @Tens1des pointed out, the omitempty is nice to have there when using testJSONMarshal so that a null is not provided in the output.

So I'm a bit torn on this issue and am leaning toward keeping the omitempty/omitzero for unmarshal-only structs.

Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com>
@codecov

codecov Bot commented Aug 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.51%. Comparing base (c4176b1) to head (8f453d9).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com>
@gmlewis
gmlewis merged commit 7314b00 into google:master Aug 21, 2026
15 checks passed
@gmlewis
gmlewis deleted the add-list-return-structs branch August 21, 2026 13:22
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.

1 participant