Skip to content

Commit 32bc3ab

Browse files
committed
update getGraphList type check
1 parent 40986ba commit 32bc3ab

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

util.go

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,21 +76,22 @@ func getGraphType(tipe reflect.Type) Output {
7676
}
7777

7878
func getGraphList(tipe reflect.Type) *List {
79-
switch tipe {
80-
case reflect.TypeOf([]int{}):
81-
case reflect.TypeOf([]int8{}):
82-
case reflect.TypeOf([]int32{}):
83-
case reflect.TypeOf([]int64{}):
84-
return NewList(Int)
85-
case reflect.TypeOf([]bool{}):
86-
return NewList(Boolean)
87-
case reflect.TypeOf([]float32{}):
88-
case reflect.TypeOf([]float64{}):
89-
return NewList(Float)
90-
case reflect.TypeOf([]string{}):
91-
return NewList(String)
79+
if tipe.Kind() == reflect.Slice {
80+
switch tipe.Elem().Kind() {
81+
case reflect.Int:
82+
case reflect.Int8:
83+
case reflect.Int32:
84+
case reflect.Int64:
85+
return NewList(Int)
86+
case reflect.Bool:
87+
return NewList(Boolean)
88+
case reflect.Float32:
89+
case reflect.Float64:
90+
return NewList(Float)
91+
case reflect.String:
92+
return NewList(String)
93+
}
9294
}
93-
9495
// finaly bind object
9596
t := reflect.New(tipe.Elem())
9697
name := strings.Replace(fmt.Sprint(tipe.Elem()), ".", "_", -1)

0 commit comments

Comments
 (0)