-
-
Notifications
You must be signed in to change notification settings - Fork 61
Description
Is your feature request related to a problem? Please describe.
We maintain a large amount of functions for multiple kinds of "resources". We would like to make it easier to maintain by splitting the converter interfaces for each "resources" to improve the maintainability of this code.
Describe the solution you'd like
I'd like to be able to have a single goverter converter in which I embed an unlimited amount of interfaces for each of my resources:
package main
type Person struct {
Name string
}
type PersonSchema struct {
Name string
}
type PersonConverter interface {
PersonFromSchema(PersonSchema) Person
SchemaFromPerson(Person) PersonSchema
}
type Address struct {
Street string
ZipCode string
}
type AddressSchema struct {
Street string
ZipCode string
}
type AddressConverter interface {
AddressFromSchema(AddressSchema) Address
SchemaFromAddress(Address) AddressSchema
}
// goverter:converter
type Converter interface {
PersonConverter
AddressConverter
}But this fails with:
$ go run github.com/jmattheis/goverter/cmd/goverter gen .
/test.go:32:1: type Converter: method must have one name
exit status 1Describe alternatives you've considered
We could use a different converter for each resources, but since we have resources that cross boundaries, we need to share the common converter configuration (and extends) for all our conversion and we prefer not to duplicate the goverter config.
Please 👍 this issue if you like this functionality. If you have a specific use-case in mind, feel free to comment it.