Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom faker functions #48

Closed
torwald-sergesson opened this issue Apr 2, 2019 · 2 comments
Closed

Custom faker functions #48

torwald-sergesson opened this issue Apr 2, 2019 · 2 comments

Comments

@torwald-sergesson
Copy link

It will be fine to have ability to register custom functions which can be used in in structure tags:

func MyStrangeName() string {
    return "strange name"
}

type MyStruct struct {
    name string `fake:"my_strange_name"`
}

func main() {
    gofakeit.RegisterString("my_strange_name", MyStrangeName)
    // apply
   var s MyStruct
   gofakeit.Struct(&s)   
}
@brianvoe
Copy link
Owner

brianvoe commented Apr 2, 2019

I do like that idea when i have the time to put more work into the struct part of gofakeit ill be sure to add that. Thanks

@brianvoe
Copy link
Owner

This was added in version 5. I implemented what call FuncLookups you can run AddLookupData and that will register custom functions that will be available in struct building.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants