Repository navigation
feat: support struct type providers & max field depth on struct - #80
Conversation
7cbd66e to
7d60b71
Compare
7d60b71 to
998479f
Compare
|
@bxcodec any feedback on this PR ? |
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for struct type providers and field depth limiting to improve faker performance and flexibility. It allows users to register custom providers for specific struct types (like time.Time or big.Rat) and limit how deeply nested struct fields are populated to prevent long generation times for complex objects.
- Adds
StructTypeProvidersmap to register custom providers for specific struct types - Introduces
MaxFieldDepthOptionto control how deeply struct fields are populated - Updates struct generation logic to use type providers and respect field depth limits
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| pkg/options/options.go | Adds struct type provider map, field depth option, and related configuration functions |
| pkg/errors/generic.go | Adds error message for unsupported non-struct types |
| faker_test.go | Adds comprehensive tests for struct type providers and field depth limiting |
| faker.go | Updates struct generation to use type providers and implement field depth controls |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
please ignore AI review if doesn't make sense |
|
@bxcodec pushed a fix on the possible |
|
I just merged, I just realized, we should have added a small documentation about how to use the new feature. |

Allow users to register struct type providers, useful for types like Redefined time or big.Rat
Allow users to limit the struct field depth generator as time to generate large real-life complex objects takes a very long time, example of 4 objects added for testing with default generator conditions took more than 60 seconds