-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdefault.go
103 lines (88 loc) · 1.44 KB
/
default.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package safe
import (
"time"
)
func TimeOrDefault(t *time.Time, def func() time.Time) time.Time {
if t == nil {
return def()
}
return *t
}
func StrOrDefault(s *string, def func() string) string {
if s == nil {
return def()
}
return *s
}
func IOrDefault(n *int, def func() int) int {
if n == nil {
return def()
}
return *n
}
func I8OrDefault(n *int8, def func() int8) int8 {
if n == nil {
return def()
}
return *n
}
func I16OrDefault(n *int16, def func() int16) int16 {
if n == nil {
return def()
}
return *n
}
func I32OrDefault(n *int32, def func() int32) int32 {
if n == nil {
return def()
}
return *n
}
func I64OrDefault(n *int64, def func() int64) int64 {
if n == nil {
return def()
}
return *n
}
func UiOrDefault(n *uint, def func() uint) uint {
if n == nil {
return def()
}
return *n
}
func Ui8OrDefault(n *uint8, def func() uint8) uint8 {
if n == nil {
return def()
}
return *n
}
func Ui16OrDefault(n *uint16, def func() uint16) uint16 {
if n == nil {
return def()
}
return *n
}
func Ui32OrDefault(n *uint32, def func() uint32) uint32 {
if n == nil {
return def()
}
return *n
}
func Ui64OrDefault(n *uint64, def func() uint64) uint64 {
if n == nil {
return def()
}
return *n
}
func F32OrDefault(n *float32, def func() float32) float32 {
if n == nil {
return def()
}
return *n
}
func F64OrDefault(n *float64, def func() float64) float64 {
if n == nil {
return def()
}
return *n
}