jmattheis / goverter

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

Hang / infinite loop on nested recursive slice structs #73

Closed amiralies closed 1 year ago

amiralies commented 1 year ago

Describe the bug Goverter hangs on following input

To Reproduce


// goverter:converter
type Converter interface {
    Convert(source ShopDto) ShopModel
}

type ShopDto struct {
    Name  string
    Owner *PersonDto
}

type ShopModel struct {
    Name  string
    Owner *PersonModel
}

type PersonDto struct {
    Name    string
    Friends []PersonDto
}

type PersonModel struct {
    Name    string
    Friends []PersonModel
}

// or 
type PersonDto struct {
    Name    string
    Friends *[]PersonDto
}

type PersonModel struct {
    Name    string
    Friends *[]PersonModel
}

workaround is to add typ converter signature for persondto -> personmodel to converter interface

jmattheis commented 1 year ago

Thanks for the report, the problem should be fixed with v0.17.4. Could you verify that it works for your use-case?

The endless loop was introduced in v0.14.0.

amiralies commented 1 year ago

It seems it's fixed! thanks for the quick fix!