-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpointers.go
166 lines (151 loc) · 3.47 KB
/
pointers.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
package jsony
// PBool is a pointer version of [Bool].
//
// If the given value is nil, it will be serialized to null.
// Otherwise, behaves exactly as [Bool].
func PBool(v *bool) Encoder {
if v == nil {
return Null
}
return Bool(*v)
}
// PInt is a pointer version of [Int].
//
// If the given value is nil, it will be serialized to null.
// Otherwise, behaves exactly as [Int].
func PInt(v *int) Encoder {
if v == nil {
return Null
}
return Int(*v)
}
// PInt8 is a pointer version of [Int8].
//
// If the given value is nil, it will be serialized to null.
// Otherwise, behaves exactly as [Int8].
func PInt8(v *int8) Encoder {
if v == nil {
return Null
}
return Int8(*v)
}
// PInt16 is a pointer version of [Int16].
//
// If the given value is nil, it will be serialized to null.
// Otherwise, behaves exactly as [Int16].
func PInt16(v *int16) Encoder {
if v == nil {
return Null
}
return Int16(*v)
}
// PInt32 is a pointer version of [Int32].
//
// If the given value is nil, it will be serialized to null.
// Otherwise, behaves exactly as [Int32].
func PInt32(v *int32) Encoder {
if v == nil {
return Null
}
return Int32(*v)
}
// PInt64 is a pointer version of [Int64].
//
// If the given value is nil, it will be serialized to null.
// Otherwise, behaves exactly as [Int64].
func PInt64(v *int64) Encoder {
if v == nil {
return Null
}
return Int64(*v)
}
// PUInt is a pointer version of [UInt].
//
// If the given value is nil, it will be serialized to null.
// Otherwise, behaves exactly as [UInt].
func PUInt(v *uint) Encoder {
if v == nil {
return Null
}
return UInt(*v)
}
// PUInt8 is a pointer version of [UInt8].
//
// If the given value is nil, it will be serialized to null.
// Otherwise, behaves exactly as [UInt8].
func PUInt8(v *uint8) Encoder {
if v == nil {
return Null
}
return UInt8(*v)
}
// PUInt16 is a pointer version of [UInt16].
//
// If the given value is nil, it will be serialized to null.
// Otherwise, behaves exactly as [UInt16].
func PUInt16(v *uint16) Encoder {
if v == nil {
return Null
}
return UInt16(*v)
}
// PUInt32 is a pointer version of [UInt32].
//
// If the given value is nil, it will be serialized to null.
// Otherwise, behaves exactly as [UInt32].
func PUInt32(v *uint32) Encoder {
if v == nil {
return Null
}
return UInt32(*v)
}
// PUInt64 is a pointer version of [UInt64].
//
// If the given value is nil, it will be serialized to null.
// Otherwise, behaves exactly as [UInt64].
func PUInt64(v *uint64) Encoder {
if v == nil {
return Null
}
return UInt64(*v)
}
// PUIntPtr is a pointer version of [UIntPtr].
//
// If the given value is nil, it will be serialized to null.
// Otherwise, behaves exactly as [UIntPtr].
func PUIntPtr(v *uintptr) Encoder {
if v == nil {
return Null
}
return UIntPtr(*v)
}
// PFloat32 is a pointer version of [Float32].
//
// If the given value is nil, it will be serialized to null.
// Otherwise, behaves exactly as [Float32].
func PFloat32(v *float32) Encoder {
if v == nil {
return Null
}
return Float32(*v)
}
// PFloat64 is a pointer version of [Float64].
//
// If the given value is nil, it will be serialized to null.
// Otherwise, behaves exactly as [Float64].
func PFloat64(v *float64) Encoder {
if v == nil {
return Null
}
return Float64(*v)
}
// PString is a pointer version of [String].
//
// If the given value is nil, it will be serialized to null.
// Otherwise, behaves exactly as [String].
func PString(v *string) Encoder {
if v == nil {
return Null
}
return String(*v)
}