-
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathexample_with_limits_test.go
More file actions
71 lines (65 loc) · 1.52 KB
/
example_with_limits_test.go
File metadata and controls
71 lines (65 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package faker_test
import (
"encoding/json"
"fmt"
"github.com/go-faker/faker/v4"
"github.com/go-faker/faker/v4/pkg/options"
)
type FirstStruct struct {
OneName string
Second []SecondStruct
}
type SecondStruct struct {
SecondName string
Third map[string]ThirdStruct
}
type ThirdStruct struct {
ThirdName string
Forth *ForthStruct
}
type ForthStruct struct {
ForthName string
First *FirstStruct
}
// Single fake function can be used for retrieving particular values.
func Example_singleFakeDatax() {
var fs FirstStruct
_ = faker.FakeData(&fs, options.WithRandomMapAndSliceMinSize(2), options.WithRandomMapAndSliceMaxSize(3),
options.WithMaxFieldDepthOption(3))
jsonData, _ := json.MarshalIndent(fs, "", " ")
fmt.Printf("\n%s\n", jsonData)
/*
Result:
{
"OneName": "YXjukTxAUhrZUYjwUoomQleqE",
"Second": [
{
"SecondName": "TftEhuEhbxnyVQwNJPGuUmTYy",
"Third": {
"LnZwwGyrYdiouITSkGlIRCpLj": {
"ThirdName": "",
"Forth": null
},
"vpQoyQXORYvyTHlckVJiSHsPO": {
"ThirdName": "",
"Forth": null
}
}
},
{
"SecondName": "CVCBTSJmaIHXSnfQPhHbAIRru",
"Third": {
"BmDkdCFiOVylYPljyptkmArIb": {
"ThirdName": "",
"Forth": null
},
"XdvTacNkbmSSvcAounuORynrp": {
"ThirdName": "",
"Forth": null
}
}
}
]
}
*/
}