-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.go
More file actions
272 lines (196 loc) · 6.39 KB
/
common.go
File metadata and controls
272 lines (196 loc) · 6.39 KB
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
package schema
import (
"github.com/creasty/defaults"
"github.com/jinzhu/copier"
"github.com/volatiletech/null"
)
// NullBool is a nullable bool.
type NullBool = null.Bool
var (
// NewNullBool creates a new Bool
NewNullBool = null.NewBool
// NullBoolFrom creates a new Bool that will always be valid.
NullBoolFrom = null.BoolFrom
// NullBoolFromPtr creates a new Bool that will be null if f is nil.
NullBoolFromPtr = null.BoolFromPtr
)
// NullByte is an nullable int.
type NullByte = null.Byte
var (
// NewNullByte creates a new Byte
NewNullByte = null.NewByte
// NullByteFrom creates a new Byte that will always be valid.
NullByteFrom = null.ByteFrom
// NullByteFromPtr creates a new Byte that be null if i is nil.
NullByteFromPtr = null.ByteFromPtr
)
// // NullBytes is a global byte slice of JSON null
// var NullBytes = null.NullBytes
// NullBytes is a nullable []byte.
type NullBytes = null.Bytes
var (
// NewNullBytes creates a new Bytes
NewNullBytes = null.NewBytes
// NullBytesFrom creates a new Bytes that will be invalid if nil.
NullBytesFrom = null.BytesFrom
// NullBytesFromPtr creates a new Bytes that will be invalid if nil.
NullBytesFromPtr = null.BytesFrom
)
// NullFloat32 is a nullable float32.
type NullFloat32 = null.Float32
var (
// NewNullFloat32 creates a new Float32
NewNullFloat32 = null.NewFloat32
// NullFloat32From creates a new Float32 that will always be valid.
NullFloat32From = null.Float32From
// NullFloat32FromPtr creates a new Float32 that be null if f is nil.
NullFloat32FromPtr = null.Float32FromPtr
)
// NullFloat64 is a nullable float64.
type NullFloat64 = null.Float64
var (
// NewNullFloat64 creates a new Float64
NewNullFloat64 = null.NewFloat64
// NullFloat64From creates a new Float64 that will always be valid.
NullFloat64From = null.Float64From
// NullFloat64FromPtr creates a new Float64 that be null if f is nil.
NullFloat64FromPtr = null.Float64FromPtr
)
// NullInt is a nullable Int.
type NullInt = null.Int
var (
// NewNullInt creates a new Int
NewNullInt = null.NewInt
// NullIntFrom creates a new Int that will always be valid.
NullIntFrom = null.IntFrom
// NullIntFromPtr creates a new Int that be null if f is nil.
NullIntFromPtr = null.IntFromPtr
)
// NullInt16 is a nullable Int16.
type NullInt16 = null.Int16
var (
// NewNullInt16 creates a new Int
NewNullInt16 = null.NewInt16
// NullInt16From creates a new Int that will always be valid.
NullInt16From = null.Int16From
// NullInt16FromPtr creates a new Int that be null if f is nil.
NullInt16FromPtr = null.Int16FromPtr
)
// NullInt32 is a nullable Int32.
type NullInt32 = null.Int32
var (
// NewNullInt32 creates a new Int
NewNullInt32 = null.NewInt32
// NullInt32From creates a new Int that will always be valid.
NullInt32From = null.Int32From
// NullInt32FromPtr creates a new Int that be null if f is nil.
NullInt32FromPtr = null.Int32FromPtr
)
// NullInt64 is a nullable Int64.
type NullInt64 = null.Int64
var (
// NewNullInt64 creates a new Int
NewNullInt64 = null.NewInt64
// NullInt64From creates a new Int that will always be valid.
NullInt64From = null.Int64From
// NullInt64FromPtr creates a new Int that be null if f is nil.
NullInt64FromPtr = null.Int64FromPtr
)
// NullInt8 is a nullable Int8.
type NullInt8 = null.Int8
var (
// NewNullInt8 creates a new Int
NewNullInt8 = null.NewInt8
// NullInt8From creates a new Int that will always be valid.
NullInt8From = null.Int8From
// NullInt8FromPtr creates a new Int that be null if f is nil.
NullInt8FromPtr = null.Int8FromPtr
)
// NullJSON is a nullable JSON.
type NullJSON = null.JSON
var (
// NewNullJSON creates a new Int
NewNullJSON = null.NewJSON
// NullJSONFrom creates a new Int that will always be valid.
NullJSONFrom = null.JSONFrom
// NullJSONFromPtr creates a new Int that be null if f is nil.
NullJSONFromPtr = null.JSONFromPtr
)
// NullString is a nullable String.
type NullString = null.String
var (
// NewNullString creates a new Int
NewNullString = null.NewString
// NullStringFrom creates a new Int that will always be valid.
NullStringFrom = null.StringFrom
// NullStringFromPtr creates a new Int that be null if f is nil.
NullStringFromPtr = null.StringFromPtr
)
// NullUint is a nullable Uint.
type NullUint = null.Uint
var (
// NewNullUint creates a new Int
NewNullUint = null.NewUint
// NullUintFrom creates a new Int that will always be valid.
NullUintFrom = null.UintFrom
// NullUintFromPtr creates a new Int that be null if f is nil.
NullUintFromPtr = null.UintFromPtr
)
// NullUint16 is a nullable Uint16.
type NullUint16 = null.Uint16
var (
// NewNullUint16 creates a new Int
NewNullUint16 = null.NewUint16
// NullUint16From creates a new Int that will always be valid.
NullUint16From = null.Uint16From
// NullUint16FromPtr creates a new Int that be null if f is nil.
NullUint16FromPtr = null.Uint16FromPtr
)
// NullUint32 is a nullable Uint32.
type NullUint32 = null.Uint32
var (
// NewNullUint32 creates a new Int
NewNullUint32 = null.NewUint32
// NullUint32From creates a new Int that will always be valid.
NullUint32From = null.Uint32From
// NullUint32FromPtr creates a new Int that be null if f is nil.
NullUint32FromPtr = null.Uint32FromPtr
)
// NullUint64 is a nullable Uint64.
type NullUint64 = null.Uint64
var (
// NewNullUint64 creates a new Int
NewNullUint64 = null.NewUint64
// NullUint64From creates a new Int that will always be valid.
NullUint64From = null.Uint64From
// NullUint64FromPtr creates a new Int that be null if f is nil.
NullUint64FromPtr = null.Uint64FromPtr
)
// NullUint8 is a nullable Uint8.
type NullUint8 = null.Uint8
var (
// NewNullUint8 creates a new Int
NewNullUint8 = null.NewUint8
// NullUint8From creates a new Int that will always be valid.
NullUint8From = null.Uint8From
// NullUint8FromPtr creates a new Int that be null if f is nil.
NullUint8FromPtr = null.Uint8FromPtr
)
// NullTime is a nullable Time.
type NullTime = null.Time
var (
// NewNullTime creates a new Int
NewNullTime = null.NewTime
// NullTimeFrom creates a new Int that will always be valid.
NullTimeFrom = null.TimeFrom
// NullTimeFromPtr creates a new Int that be null if f is nil.
NullTimeFromPtr = null.TimeFromPtr
)
// SetDefaults sets the defaults for given struct
func SetDefaults(obj interface{}) error {
return defaults.Set(obj)
}
// Set sets the fields for given struct
func Set(obj, src interface{}) error {
return copier.Copy(obj, src)
}