-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathparsing.go
62 lines (49 loc) · 1.27 KB
/
parsing.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
package sanitize
import (
"strconv"
)
func parseInt(str string) (int, error) {
v, err := strconv.ParseInt(str, 10, 64)
return int(v), err
}
func parseInt8(str string) (int8, error) {
v, err := strconv.ParseInt(str, 10, 8)
return int8(v), err
}
func parseInt16(str string) (int16, error) {
v, err := strconv.ParseInt(str, 10, 16)
return int16(v), err
}
func parseInt32(str string) (int32, error) {
v, err := strconv.ParseInt(str, 10, 32)
return int32(v), err
}
func parseInt64(str string) (int64, error) {
return strconv.ParseInt(str, 10, 64)
}
func parseUint(str string) (uint, error) {
v, err := strconv.ParseUint(str, 10, 64)
return uint(v), err
}
func parseUint8(str string) (uint8, error) {
v, err := strconv.ParseUint(str, 10, 8)
return uint8(v), err
}
func parseUint16(str string) (uint16, error) {
v, err := strconv.ParseUint(str, 10, 16)
return uint16(v), err
}
func parseUint32(str string) (uint32, error) {
v, err := strconv.ParseUint(str, 10, 32)
return uint32(v), err
}
func parseUint64(str string) (uint64, error) {
return strconv.ParseUint(str, 10, 64)
}
func parseFloat32(str string) (float32, error) {
v, err := strconv.ParseFloat(str, 32)
return float32(v), err
}
func parseFloat64(str string) (float64, error) {
return strconv.ParseFloat(str, 64)
}