faker
faker copied to clipboard
Adding nested tags for slice of strings
As pointed out in the issue #37 (faker slice of urls don't work), struct fields do not support faker tags for the underlying field data type in case of slices. Taking a subsection of the mentioned issue
type Entity struct {
...
Uris []string `faker:"slice_len=3, url"` // makes all structure empty. I just need slice with 3 urls
...
}
In the above code taken from issue #37 the Uris
slice will not take into account the url
tag.
For the mentioned issue, I suggest an extension to the faker struct tags syntax to allow nested tags with following syntax:
type SomeType struct {
...
SomeSliceOfStrings []string `faker:"<tags for slice>, [<tags for string>]"`
...
}
// Example
type Emails struct {
EmailList []string `faker:"slice_len=3, [email]"`
}
The PR is still a work in progress but I would like to hear more and discuss on the idea of using nested tags.