@@ -12,15 +12,17 @@ import (
12
12
13
13
// LoadFromReader - Load csv from an io.Reader and put it in a array of the destination's type using tags.
14
14
// Example:
15
- // tabOfMyStruct := []MyStruct{}
16
- // err := Load(
17
- // myIoReader,
18
- // &tabOfMyStruct,
19
- // CsvOptions{
20
- // Separator: ';',
21
- // Header: []string{"header1", "header2", "header3"
22
- // }
23
- // })
15
+ //
16
+ // tabOfMyStruct := []MyStruct{}
17
+ // err := Load(
18
+ // myIoReader,
19
+ // &tabOfMyStruct,
20
+ // CsvOptions{
21
+ // Separator: ';',
22
+ // Header: []string{"header1", "header2", "header3"
23
+ // }
24
+ // })
25
+ //
24
26
// @param file: the io.Reader.
25
27
// @param destination: object where to store the result.
26
28
// @param options (optional): options for the csv parsing.
@@ -55,15 +57,17 @@ func LoadFromReader(file io.Reader, destination interface{}, options ...CsvOptio
55
57
56
58
// LoadFromPath - Load csv from a path and put it in a array of the destination's type using tags.
57
59
// Example:
58
- // tabOfMyStruct := []MyStruct{}
59
- // err := Load(
60
- // "my_csv_file.csv",
61
- // &tabOfMyStruct,
62
- // CsvOptions{
63
- // Separator: ';',
64
- // Header: []string{"header1", "header2", "header3"
65
- // }
66
- // })
60
+ //
61
+ // tabOfMyStruct := []MyStruct{}
62
+ // err := Load(
63
+ // "my_csv_file.csv",
64
+ // &tabOfMyStruct,
65
+ // CsvOptions{
66
+ // Separator: ';',
67
+ // Header: []string{"header1", "header2", "header3"
68
+ // }
69
+ // })
70
+ //
67
71
// @param path: the path of the csv file.
68
72
// @param destination: object where to store the result.
69
73
// @param options (optional): options for the csv parsing.
@@ -85,15 +89,17 @@ func LoadFromPath(path string, destination interface{}, options ...CsvOptions) e
85
89
86
90
// LoadFromString - Load csv from string and put it in a array of the destination's type using tags.
87
91
// Example:
88
- // tabOfMyStruct := []MyStruct{}
89
- // err := Load(
90
- // myString,
91
- // &tabOfMyStruct,
92
- // CsvOptions{
93
- // Separator: ';',
94
- // Header: []string{"header1", "header2", "header3"
95
- // }
96
- // })
92
+ //
93
+ // tabOfMyStruct := []MyStruct{}
94
+ // err := Load(
95
+ // myString,
96
+ // &tabOfMyStruct,
97
+ // CsvOptions{
98
+ // Separator: ';',
99
+ // Header: []string{"header1", "header2", "header3"
100
+ // }
101
+ // })
102
+ //
97
103
// @param str: the string.
98
104
// @param destination: object where to store the result.
99
105
// @param options (optional): options for the csv parsing.
@@ -196,6 +202,18 @@ func storeValue(rawValue string, valRv reflect.Value) error {
196
202
switch valRv .Kind () {
197
203
case reflect .String :
198
204
valRv .SetString (rawValue )
205
+ case reflect .Uint32 :
206
+ fallthrough
207
+ case reflect .Uint64 :
208
+ fallthrough
209
+ case reflect .Uint :
210
+ value , err := strconv .ParseUint (rawValue , 10 , 64 )
211
+ if err != nil && rawValue != "" {
212
+ return fmt .Errorf ("error parsing uint '%v':\n ==> %v" , rawValue , err )
213
+ }
214
+ valRv .SetUint (value )
215
+ case reflect .Int32 :
216
+ fallthrough
199
217
case reflect .Int64 :
200
218
fallthrough
201
219
case reflect .Int :
0 commit comments