-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
schema.go
59 lines (56 loc) · 1.3 KB
/
schema.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
package nulls
import "reflect"
type register func(interface{}, func(string) reflect.Value)
// RegisterWithSchema allows for the nulls package to be used with http://www.gorillatoolkit.org/pkg/schema#Converter
func RegisterWithSchema(reg register) {
reg(String{}, func(s string) reflect.Value {
ns := String{}
ns.Scan(s)
return reflect.ValueOf(ns)
})
reg(Bool{}, func(s string) reflect.Value {
ns := Bool{}
ns.Scan(s)
return reflect.ValueOf(ns)
})
reg(ByteSlice{}, func(s string) reflect.Value {
ns := ByteSlice{}
ns.Scan(s)
return reflect.ValueOf(ns)
})
reg(Float32{}, func(s string) reflect.Value {
ns := Float32{}
ns.Scan(s)
return reflect.ValueOf(ns)
})
reg(Float64{}, func(s string) reflect.Value {
ns := Float64{}
ns.Scan(s)
return reflect.ValueOf(ns)
})
reg(Int{}, func(s string) reflect.Value {
ns := Int{}
ns.Scan(s)
return reflect.ValueOf(ns)
})
reg(Int32{}, func(s string) reflect.Value {
ns := Int32{}
ns.Scan(s)
return reflect.ValueOf(ns)
})
reg(Int64{}, func(s string) reflect.Value {
ns := Int64{}
ns.Scan(s)
return reflect.ValueOf(ns)
})
reg(Time{}, func(s string) reflect.Value {
ns := Time{}
ns.Scan(s)
return reflect.ValueOf(ns)
})
reg(UInt32{}, func(s string) reflect.Value {
ns := UInt32{}
ns.Scan(s)
return reflect.ValueOf(ns)
})
}