jmattheis / goverter

Generate type-safe Go converters by defining signatures of different types.
https://goverter.jmattheis.de/
MIT License
546 stars 48 forks source link

Add struct tag support for field matching #164

Open kb-sp opened 3 weeks ago

kb-sp commented 3 weeks ago

This PR adds support for using struct tags to match variable names.

Feedback welcome!

Following up on #132 this adds a new option that takes the name of the tag to use for matching. For example:

// goverter:converter
// goverter:matchTag json

Tag matching is not performed if matchTag is not set, and matching falls back to standard code paths.

Docs have been updated, and functionality seems good on my code base.

codecov[bot] commented 3 weeks ago

Codecov Report

Attention: Patch coverage is 71.69811% with 15 lines in your changes missing coverage. Please review.

Project coverage is 95.13%. Comparing base (076c25f) to head (ecdb0b6).

Files with missing lines Patch % Lines
xtype/type.go 65.11% 14 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #164 +/- ## ========================================== - Coverage 96.53% 95.13% -1.40% ========================================== Files 46 44 -2 Lines 2250 2715 +465 ========================================== + Hits 2172 2583 +411 - Misses 53 109 +56 + Partials 25 23 -2 ```

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