jaswdr / faker

:rocket: Ultimate fake data generator for Go with zero dependencies

Home Page:https://pkg.go.dev/github.com/jaswdr/faker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

bigfoot31 opened this issue · comments

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):

  • OS: macOS 12.2.1
  • go version output: go version go1.17.3 darwin/amd64

@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?

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

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

type A struct {
	ChildrenType1 []*A `fake:"skip"`
}

I'm taking a look on this