-
Notifications
You must be signed in to change notification settings - Fork 0
/
scan.go
74 lines (67 loc) · 1.13 KB
/
scan.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
package corroclient
func scanJSONNumber(number float64, d interface{}) error {
switch dest := d.(type) {
case *int:
*dest = int(number)
return nil
case *int8:
*dest = int8(number)
return nil
case *int16:
*dest = int16(number)
return nil
case *int32:
*dest = int32(number)
return nil
case *int64:
*dest = int64(number)
return nil
case *uint:
*dest = uint(number)
return nil
case *uint8:
*dest = uint8(number)
return nil
case *uint16:
*dest = uint16(number)
return nil
case *uint32:
*dest = uint32(number)
return nil
case *uint64:
*dest = uint64(number)
return nil
case *float32:
*dest = float32(number)
return nil
case *float64:
*dest = float64(number)
return nil
case *bool:
*dest = number != 0
return nil
}
return ErrScan
}
func scanJSONString(s string, dest any) error {
if dest == nil {
return ErrScan
}
switch d := dest.(type) {
case *string:
*d = s
return nil
case *[]byte:
*d = []byte(s)
return nil
}
return ErrScan
}
func scanJSONBool(b any, dest interface{}) error {
switch d := dest.(type) {
case *bool:
*d = b.(bool)
return nil
}
return ErrScan
}