jmattheis / goverter

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

Generator throws an error when using inheritance and source/target as pointers #36

Closed barteksc closed 1 year ago

barteksc commented 1 year ago

Describe the bug Generator throws an error when using inheritance and source/target as pointers.

To Reproduce This generates a correct code

// goverter:converter
type Converter interface {
    // goverter:mapIdentity Base
    Convert(in In) Out
}

type In struct {
    Name string
    Age  int
}

type Out struct {
    Base
    Age int
}

type Base struct {
    Name string
}

But this throws an error

// goverter:converter
type Converter interface {
    // goverter:mapIdentity Base
    Convert(in *In) *Out
}

type In struct {
    Name string
    Age  int
}

type Out struct {
    Base
    Age int
}

type Base struct {
    Name string
}
Error while creating converter method:
    func (mappers.Converter).Convert(in *mappers.In) *mappers.Out

| *mappers.In
|
|     | mappers.In
|     |
|     |
|     |
source*.???
target*.Base
|     | |
|     | | mappers.Base
|     |
|     | mappers.Out
|
| *mappers.Out

Cannot match the target field with the source entry: "Base" does not exist.
exit status 1

Expected behavior I would expect it to correctly generate a converter, but maybe I'm missing something.

jmattheis commented 1 year ago

Thanks for your report. The bug is fixed in v0.10.1.