go-simpler / musttag

🚔 Enforce field tags in (un)marshaled structs
https://go-simpler.org/musttag
Mozilla Public License 2.0
36 stars 9 forks source link

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

Closed Adjective-Object closed 7 months ago

Adjective-Object commented 8 months ago

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.

codecov[bot] commented 8 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

tmzane commented 7 months ago

Thanks!