jmattheis / goverter

Generate type-safe Go converters by simply defining an interface
https://goverter.jmattheis.de/
MIT License
496 stars 46 forks source link

Support Nested Goverter Interface Definition #30

Closed Jiang-Le closed 1 year ago

Jiang-Le commented 2 years ago

i suggest goverter can support nested interface definition, so that we can assign function into different module. it will be more clear definition.

type StructA struct {
    Value  string
    Target TargetA
}

type StructB struct {
    Value  string
    Target TargetB
}

type TargetA struct {
    TA string
}

type TargetB struct {
    TB string
}

// goverter:converter
type TargetConvertor interface {
    // goverter:map TA TB
    TargetAToTargetB(a TargetA) TargetB
}

// goverter:converter
type StructConvertor interface {
    TargetConvertor 
    StructAToStructB(a StructA) StructB
}
jmattheis commented 1 year ago

You want to have converters in different modules and then they should use methods from each other? This will be difficult to implement because goverter currently only generates the converter from one package and the generate path is supplied via cli flags.