-
-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Combine nested automap and fieldmap #80
Comments
You can already achieve the same generated code by doing the following: // goverter:converter
type Converter interface {
// goverter:map . Address
Convert(FlatPerson) Person
// goverter:map Street StreetName
ConvertAddress(FlatPerson) Address
} Sadly your solution isn't that easy, because it can clash with other definitions, imagine a converter like this // goverter:converter
type Converter interface {
// goverter:map . Address
// goverter:map Street Address.StreetName
Convert(FlatPerson) Person
// goverter:map Name StreetName
ConvertAddress(FlatPerson) Address
} What should be the value for StreetName (Name or Street). I'm not fully against a change like this, but goverter must fail with a readable error when there are conflicting definitions. |
It still don't work when FlatPerson is ptr. It's a simplified version of my actual scenario. // goverter:converter
type Converter interface {
// goverter:map . Address
Convert(*FlatPerson) *Person
// goverter:map Street StreetName
ConvertAddress(*FlatPerson) Address
}
|
Try defining it as
See the mapping in the error message. It first does |
When I Combine automap and fieldmap, it doesn't work
the error message was as follows
The solution might be to add the sub context when createing subMethod
PR
It works fine.
It works fine, too, and even handles nested cases. But I don't know if there are any other problems
generated
Please 👍 this issue if you like this functionality. If you have a specific use-case in mind, feel free to comment it.
The text was updated successfully, but these errors were encountered: