Skip to content
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

feat: check whether structs within arrays/slices/maps implement a Marshaler interface #87

Merged
merged 3 commits into from
Apr 5, 2024

Conversation

Adjective-Object
Copy link
Contributor

The current implementation of interface checks only handles cases where the root type implements json.Marshal. If it does not, the type is "unpacked" to a raw struct type, which is then checked for json: tags.

This fails when the root type does not implement json.Unmarshal, but is a transparent container for a type that contains a json.Marshal; e.g. []MyType or map[string]MyType where MyType implements json.Marshal.

@tmzane tmzane self-requested a review April 5, 2024 08:10
Copy link

codecov bot commented Apr 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.45%. Comparing base (a6b60d7) to head (47c706f).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #87   +/-   ##
=======================================
  Coverage   79.45%   79.45%           
=======================================
  Files           3        3           
  Lines         219      219           
=======================================
  Hits          174      174           
  Misses         32       32           
  Partials       13       13           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

musttag.go Outdated Show resolved Hide resolved
testdata/src/tests/builtins.go Outdated Show resolved Hide resolved
musttag.go Outdated Show resolved Hide resolved
musttag.go Outdated Show resolved Hide resolved
@tmzane tmzane changed the title handle []T where T implements json.Unmarshal feat: check whether structs within arrays/slices/maps implement a Marshaler interface Apr 5, 2024
tmzane
tmzane previously approved these changes Apr 5, 2024
@tmzane tmzane merged commit 4026f8f into go-simpler:main Apr 5, 2024
7 checks passed
@tmzane
Copy link
Member

tmzane commented Apr 5, 2024

Thanks!

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.

2 participants