@@ -15,8 +15,8 @@ import (
15
15
// @param slice: an object typically of the form []struct, where the struct is using csv tags.
16
16
// @param writer: the location of where you will write the slice content to. Example: File, Stdout, etc.
17
17
// @param options (optional): options for the csv parsing.
18
- // @return an error if one occures .
19
- func DumpToWriter (slice interface {} , writer io.Writer , options ... CsvOptions ) error {
18
+ // @return an error if one occurs .
19
+ func DumpToWriter (slice any , writer io.Writer , options ... CsvOptions ) error {
20
20
// If slice is a pointer, get the value it points to.
21
21
// (if it isn't, Indirect() does nothing and returns the value it was called with).
22
22
reflectedValue := reflect .Indirect (reflect .ValueOf (slice ))
@@ -58,10 +58,10 @@ func DumpToWriter(slice interface{}, writer io.Writer, options ...CsvOptions) er
58
58
return err
59
59
}
60
60
61
- for i := 0 ; i < reflectedValue .Len (); i ++ {
62
- line := []string {}
61
+ for i := range reflectedValue .Len () {
62
+ var line []string
63
63
64
- for j := 0 ; j < reflectedValue .Type ().Elem ().NumField (); j ++ {
64
+ for j := range reflectedValue .Type ().Elem ().NumField () {
65
65
valueRv := reflectedValue .Index (i )
66
66
value := valueRv .Field (j )
67
67
tag := valueRv .Type ().Field (j ).Tag .Get (option .TagKey )
@@ -91,8 +91,8 @@ func DumpToWriter(slice interface{}, writer io.Writer, options ...CsvOptions) er
91
91
// @param slice: An object typically of the form []struct, where the struct is using csv tag.
92
92
// @param path: The file path string of where you want the file to be created.
93
93
// @param options (optional): options for the csv parsing.
94
- // @return an error if one occures .
95
- func DumpToFile (slice interface {} , path string , options ... CsvOptions ) error {
94
+ // @return an error if one occurs .
95
+ func DumpToFile (slice any , path string , options ... CsvOptions ) error {
96
96
file , err := os .Create (path )
97
97
if err != nil {
98
98
return err
@@ -108,8 +108,8 @@ func DumpToFile(slice interface{}, path string, options ...CsvOptions) error {
108
108
// DumpToString - writes a slice content into a string.
109
109
// @param slice: An object typically of the form []struct, where the struct is using csv tag.
110
110
// @param options (optional): options for the csv parsing.
111
- // @return a string and an error if one occures .
112
- func DumpToString (slice interface {} , options ... CsvOptions ) (string , error ) {
111
+ // @return a string and an error if one occurs .
112
+ func DumpToString (slice any , options ... CsvOptions ) (string , error ) {
113
113
114
114
writer := new (bytes.Buffer )
115
115
0 commit comments