forked from thoas/go-funk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunk_test.go
74 lines (65 loc) · 965 Bytes
/
funk_test.go
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
72
73
74
package funk
import "database/sql"
type Model interface {
TableName() string
}
// Bar is
type Bar struct {
Name string
Bar *Bar
Bars []*Bar
}
func (b Bar) TableName() string {
return "bar"
}
// Foo is
type Foo struct {
ID int
FirstName string `tag_name:"tag 1"`
LastName string `tag_name:"tag 2"`
Age int `tag_name:"tag 3"`
Bar *Bar
Bars []*Bar
EmptyValue sql.NullInt64
}
func (f Foo) TableName() string {
return "foo"
}
var bar = &Bar{
Name: "Test",
Bars: []*Bar{
{
Name: "Level1-1",
Bar: &Bar{
Name: "Level2-1",
},
},
{
Name: "Level1-2",
Bar: &Bar{
Name: "Level2-2",
},
},
},
}
var foo = &Foo{
ID: 1,
FirstName: "Dark",
LastName: "Vador",
Age: 30,
Bar: bar,
EmptyValue: sql.NullInt64{
Valid: true,
Int64: 10,
},
Bars: []*Bar{
bar,
bar,
},
}
var foo2 = &Foo{
ID: 1,
FirstName: "Dark",
LastName: "Vador",
Age: 30,
}