jaswdr / faker

:rocket: Ultimate fake data generator for Go with zero dependencies
https://pkg.go.dev/github.com/jaswdr/faker
MIT License
566 stars 59 forks source link

[BUG] Struct().Fill() is not correctly handling nested structures #94

Open bigfoot31 opened 2 years ago

bigfoot31 commented 2 years ago

Describe the bug goroutine stack exceeds 1000000000-byte limit

To Reproduce

type A struct {
children []*A
}
tmp := A{}
f.Struct().Fill(&tmp)

Expected behavior A clear and concise description of what you expected to happen.

Screenshots image

Desktop (please complete the following information):

jaswdr commented 1 year ago

@bigfoot31 this issue is quite old now and we have tests to validate nested structures, would you mind check if this error happens with the newest version? If still happens, can you provide a complete code sample you are using?

gboddin commented 1 year ago

It sill happens on the last tagged version and the master branch

package main

import (
    "github.com/jaswdr/faker"
)

type A struct {
    ChildrenType1 []*A
}

func main() {
    tmp := A{}
    faker.New().Struct().Fill(&tmp)
}
runtime: goroutine stack exceeds 1000000000-byte limit
runtime: sp=0xc020260408 stack=[0xc020260000, 0xc040260000]
fatal error: stack overflow
gboddin commented 1 year ago

Tips : if you don't care about the field :

type A struct {
    ChildrenType1 []*A `fake:"skip"`
}
jaswdr commented 1 year ago

I'm taking a look on this