-
Notifications
You must be signed in to change notification settings - Fork 12
/
options.go
45 lines (38 loc) · 933 Bytes
/
options.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
// Copyright [2020-2023] [guonaihong]
package pcopy
type options struct {
// // MaxDepth is the maximum depth to traverse.
// // If MaxDepth is 0, it will be treated as no limit.
// maxDepth int
// // TagName is the tag name to use.
// // If TagName is empty, it will be treated as no tag.
// tagName string
// // OnlyField is the field name to copy.
// // If OnlyField is empty, it will be treated as no field.
// OnlyField string
preheat bool
// 使用预热cache
usePreheat bool
}
type Option func(*options)
// func WithMaxDepth(maxDepth int) Option {
// return func(o *options) {
// o.maxDepth = maxDepth
// }
// }
// func WithTagName(tagName string) Option {
// return func(o *options) {
// o.tagName = tagName
// }
// }
func WithUsePreheat() Option {
return func(o *options) {
o.usePreheat = true
}
}
// 内部函数
func withPreheat() Option {
return func(o *options) {
o.preheat = true
}
}