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

Enable goverter:enum on goverter:variables mode #155

Closed sublee closed 3 months ago

sublee commented 3 months ago

Thanks for this nice project. goverter saves a lot of my time.

goverter v1.5.0 has introduced the goverter:variables conversion mode. In this mode, goverter:enum turns off unexpectedly. goverter:enum should be enabled by default by the documentation.

enum [yes|no] can be defined as CLI argument or conversion comment. enum is enabled per default.

I investigated the issue and guessed the reason for this problem. There are two default configurations DefaultConfigInterface and DefaultConfigVariables which turn on goverter:enum. DefaultConfigInterface is used for the goverter:converter mode as its name indicates, but DefaultConfigVariables is not used for the goverter:variables mode.

This patch enables DefaultConfigVariables for the goverter:variables mode to fix the problem. You can prove it by var_enum.yml test scenario I added. This scenario fails without this patch.

Thank you.

codecov[bot] commented 3 months ago

Codecov Report

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

Project coverage is 96.53%. Comparing base (b046455) to head (efefb02).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #155 +/- ## ========================================== - Coverage 96.53% 96.53% -0.01% ========================================== Files 46 46 Lines 2253 2250 -3 ========================================== - Hits 2175 2172 -3 Misses 53 53 Partials 25 25 ```

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