Skip to content

fake time doesn't work as expected #382

@B4Dmonkey

Description

@B4Dmonkey

Hi, I'm testing this library out for use, I tried generating some time test data using the example in the read me but run into parse errors

This is my example struct

type Record struct {
	ID           int64
	RecordID     string    `csv:"API_ID" fake:"{number:100000,999999}"`
	Source       string    `csv:"source" fake:"{firstname}"`
	PurchaseDate time.Time `fake:"{year}-{month}-{day}" format:"2006-01-02"`
	RecordType   string	
	CreatedAt    time.Time `fake:"{year}-{month}-{day}" format:"2006-01-02"`
}

this is how I call it

var foo Record
err := gofakeit.Struct(&foo)

and this is what im seeing in my logs

2025/03/27 16:44:13 error generating foo data 0
parsing time "1912-8-13" as "2006-01-02": cannot parse "8-13" as "01"
2025/03/27 16:44:13 error generating foo data 1
parsing time "1955-9-8" as "2006-01-02": cannot parse "9-8" as "01"

I'll try and dig into the code to see if I can figure out what's going on but just wanted to raise this as I didn't see it as a pending issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions