-
-
Notifications
You must be signed in to change notification settings - Fork 109
/
pointerx.go
92 lines (78 loc) · 1.41 KB
/
pointerx.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
package pointerx
// String returns the input value's pointer.
func String(s string) *string {
return &s
}
// StringR is the reverse to String.
func StringR(s *string) string {
if s == nil {
return ""
}
return *s
}
// Int returns the input value's pointer.
func Int(s int) *int {
return &s
}
// IntR is the reverse to Int.
func IntR(s *int) int {
if s == nil {
return int(0)
}
return *s
}
// Int32 returns the input value's pointer.
func Int32(s int32) *int32 {
return &s
}
// Int32R is the reverse to Int32.
func Int32R(s *int32) int32 {
if s == nil {
return int32(0)
}
return *s
}
// Int64 returns the input value's pointer.
func Int64(s int64) *int64 {
return &s
}
// Int64R is the reverse to Int64.
func Int64R(s *int64) int64 {
if s == nil {
return int64(0)
}
return *s
}
// Float32 returns the input value's pointer.
func Float32(s float32) *float32 {
return &s
}
// Float32R is the reverse to Float32.
func Float32R(s *float32) float32 {
if s == nil {
return float32(0)
}
return *s
}
// Float64 returns the input value's pointer.
func Float64(s float64) *float64 {
return &s
}
// Float64R is the reverse to Float64.
func Float64R(s *float64) float64 {
if s == nil {
return float64(0)
}
return *s
}
// Bool returns the input value's pointer.
func Bool(s bool) *bool {
return &s
}
// BoolR is the reverse to Bool.
func BoolR(s *bool) bool {
if s == nil {
return false
}
return *s
}