-
Notifications
You must be signed in to change notification settings - Fork 0
/
nullish.go
88 lines (74 loc) · 1.4 KB
/
nullish.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
package nullish
import (
"time"
"github.com/goccy/go-json"
"github.com/google/uuid"
"github.com/oklog/ulid/v2"
)
var NullType = []byte("null")
func NewNullFloat(float float64, valid bool) NullFloat {
return NullFloat{
Float: float,
Valid: valid,
}
}
func NewNullInt(integer int, valid bool) NullInt {
return NullInt{
Int: integer,
Valid: valid,
}
}
func NewNullString(str string, valid bool) NullString {
return NullString{
String: str,
Valid: valid,
}
}
func NewNullTime(time time.Time, valid bool) NullTime {
return NullTime{
Time: time,
Valid: valid,
}
}
func NewNullBool(boolean bool, valid bool) NullBool {
return NullBool{
Bool: boolean,
Valid: valid,
}
}
func NewNullObj(object map[string]interface{}, valid bool) NullObj {
return NullObj{
Obj: object,
Valid: valid,
}
}
func NewNullArr(array []interface{}, valid bool) NullArr {
return NullArr{
Arr: array,
Valid: valid,
}
}
func NewNullArrObj(arrayObject []map[string]interface{}, valid bool) NullArrObj {
return NullArrObj{
ArrObj: arrayObject,
Valid: valid,
}
}
func NewNullJSON(json json.RawMessage, valid bool) NullJSON {
return NullJSON{
Json: json,
Valid: valid,
}
}
func NewNullUUID(uuid uuid.UUID, valid bool) NullUUID {
return NullUUID{
UUID: uuid,
Valid: valid,
}
}
func NewNullULID(ulid ulid.ULID, valid bool) NullULID {
return NullULID{
ULID: ulid,
Valid: valid,
}
}