Closed dansimau closed 1 year ago
I'm unsure if this should be implemented, I really like explicitly defining what goverter should do as this makes things more obvious. Adding this, could produce unwanted behavior. F.ex when renaming struct fields goverter would not warn that there are more fields which have no mapping.
This would be a breaking change for us (we actually want goverter to stay strict and report missing fields by default). If you decide to take this on, please expose a global flag to enable strict behavior back on.
Having explicit missing fields definition is a nice feature, so I vote against having this behavior by default.
However, having explicit annotation for pattern matching seems like a reasonable feature to have, and also I don't see how this is a breaking change. This can be done with a new annotation like goverter:ignorePattern
I'm okay with adding another tag like goverter:ignoreMissing
that can be added to a method or the converter to support this behavior. This is similar to the proposal in #58.
With v0.16.0 you can use goverter:ignoreMissing
to ignore all missing exported fields. https://goverter.jmattheis.de/#/conversion/mapping?id=ignore If you also want to ignore unexported fields, then you've to add goverter:ignoreUnexported
Currently, fields to be ignored must be explicitly specified using a
// goverter:ignore FieldName
comment.I.e.: https://github.com/jmattheis/goverter/blob/edc349e6e6a7f48d692325a952bf4411dcef9470/builder/struct.go#L29
However, in my case I want to ignore missing fields by default.
Possible solutions I can think of:
// goverter:ignoreAll
// goverter:ignore To.*
(in my case, I could do:// goverter:ignore .*