Skip to content

Commit e713492

Browse files
committed
cleanup getArrayValues
use kind instead of entriesVal.Kind() and return nil, error
1 parent 3a8ad43 commit e713492

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

template.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func exists(path string) (bool, error) {
2929
return false, err
3030
}
3131

32-
func getArrayValues(funcName string, entries interface{}) (reflect.Value, error) {
32+
func getArrayValues(funcName string, entries interface{}) (*reflect.Value, error) {
3333
entriesVal := reflect.ValueOf(entries)
3434

3535
kind := entriesVal.Kind()
@@ -39,13 +39,13 @@ func getArrayValues(funcName string, entries interface{}) (reflect.Value, error)
3939
kind = entriesVal.Kind()
4040
}
4141

42-
switch entriesVal.Kind() {
42+
switch kind {
4343
case reflect.Array, reflect.Slice:
4444
break
4545
default:
46-
return entriesVal, fmt.Errorf("Must pass an array or slice to '%v'; received %v; kind %v", funcName, entries, kind)
46+
return nil, fmt.Errorf("Must pass an array or slice to '%v'; received %v; kind %v", funcName, entries, kind)
4747
}
48-
return entriesVal, nil
48+
return &entriesVal, nil
4949
}
5050

5151
// Generalized groupBy function

0 commit comments

Comments
 (0)