walk: deal with array
This commit is contained in:
parent
799d730d14
commit
f64d75ca45
@ -16,7 +16,7 @@ func Walk(x interface{}, fn func(string)) {
|
||||
case reflect.Struct:
|
||||
numberOfValues = val.NumField()
|
||||
getField = val.Field
|
||||
case reflect.Slice:
|
||||
case reflect.Slice, reflect.Array:
|
||||
numberOfValues = val.Len()
|
||||
getField = val.Index
|
||||
}
|
||||
|
@ -62,6 +62,14 @@ func TestWalk(t *testing.T) {
|
||||
},
|
||||
[]string{"London", "Paris"},
|
||||
},
|
||||
{
|
||||
"arrays",
|
||||
[2]Profile{
|
||||
{29, "London"},
|
||||
{33, "Paris"},
|
||||
},
|
||||
[]string{"London", "Paris"},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range cases {
|
||||
|
Loading…
Reference in New Issue
Block a user