Closed plusiv closed 7 months ago
It all comes down to how many times a function needs to run Uint64(). If you swap the order of a function that needs to run Uint64 2 times in front of a function that only needs to run it once you will alter your values.
@brianvoe I Apologize for my ignorance on this, but, I'm not understanding the point. Where do I use a uint64
twice? I'm just trying to realize how to use it in the right way.
It's ok took me a sec to wrap my head around it. Take a look at an example rand source below
type Dumb struct {
state uint64
}
// NewDumb initializes a Dumb source
func NewDumb(seed uint64) *Dumb {
d := &Dumb{}
d.Seed(seed)
return d
}
func (d *Dumb) Seed(seed uint64) {
d.state = seed
}
// Uint64 returns the next number in the sequence, incrementing the state.
func (d *Dumb) Uint64() uint64 {
d.state += 1
return d.state
}
So every time Uint64 is run it generates a new number.
In Gofakeit some functions may need to run Uint64() multiple times. Thus if you swap fields around, then you get an alternative output cause your previous function was given a different value then the order it was in before.
I just reread your initial issue and if your just having issues that one struct isnt being called it sounds like it caught an issue in the previous field. Struct returns an error so you should probably look at that.
I dont think this will work ExpirationDate time.Time fake:"{year}-{month}-{day}"
that might be your issue
I just reread your initial issue and if your just having issues that one struct isnt being called it sounds like it caught an issue in the previous field. Struct returns an error so you should probably look at that.
I dont think this will work ExpirationDate time.Time
fake:"{year}-{month}-{day}"
that might be your issue
You're right, I was specifying that tag in a wrong way. Fixing it worked!
Thank you so much.
No problem.
Description
I'm trying to generate random data for the struct
DNI
which have another two nested structs (DocInfo
andCitizenInfo
), for an unknown reason when I putDocInfo
beforeCitizenInfo
, theCitizenInfo
fake data is not being generated.Output:
Otherwise, putting the
CitizenInfo
beforeDocInfo
both structure's fake data are generated as spected.Output:
Is there any importance in the order?