-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdef_lazyinit.go
72 lines (61 loc) · 1.62 KB
/
def_lazyinit.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
package evendeep
import (
"reflect"
"sync"
)
var (
onceLazyInitRoutines sync.Once //nolint:gochecknoglobals //i know that
copyToRoutines map[reflect.Kind]copyfn //nolint:gochecknoglobals //i know that
otherLazyRoutines []func() //nolint:gochecknoglobals //i know that
)
type copyfn func(c *cpController, params *Params, from, to reflect.Value) (err error)
func lazyInitRoutines() {
onceLazyInitRoutines.Do(func() {
copyToRoutines = map[reflect.Kind]copyfn{ //nolint:exhaustive //also kind har human-right
reflect.Ptr: copyPointer,
reflect.Uintptr: copyUintptr,
reflect.UnsafePointer: copyUnsafePointer,
reflect.Chan: copyChan,
reflect.Interface: copyInterface,
reflect.Struct: copyStruct,
reflect.Slice: copySlice,
reflect.Array: copyArray,
reflect.Map: copyMap,
// reflect.Func: copyFunc,
// Invalid Kind = iota
// Bool
// Int
// Int8
// Int16
// Int32
// Int64
// Uint
// Uint8
// Uint16
// Uint32
// Uint64
// Uintptr
// Float32
// Float64
// Complex64
// Complex128
// Array
// Chan
// Func
// Interface
// Map
// Ptr
// Slice
// Struct
// String
// UnsafePointer
}
for _, fn := range otherLazyRoutines {
if fn != nil {
fn()
}
}
})
}
func registerInitRoutines(fn func()) { otherRoutines = append(otherRoutines, fn) } //nolint:lll,unused,deadcode //usable
func registerLazyInitRoutines(fn func()) { otherLazyRoutines = append(otherLazyRoutines, fn) } //nolint:lll,unused,deadcode //usable