Skip to content

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

Merged
tmzane merged 3 commits intogo-simpler:mainfrom
Adjective-Object:main
Apr 5, 2024
Merged

feat: check whether structs within arrays/slices/maps implement a Marshaler interface#87
tmzane merged 3 commits intogo-simpler:mainfrom
Adjective-Object:main

Conversation

@Adjective-Object
Copy link
Copy Markdown
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
@codecov
Copy link
Copy Markdown

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.

@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 self-requested a review April 5, 2024 13:10
@tmzane tmzane merged commit 4026f8f into go-simpler:main Apr 5, 2024
@tmzane
Copy link
Copy Markdown
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