File tree Expand file tree Collapse file tree 1 file changed +9
-11
lines changed
Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -77,17 +77,15 @@ func FetchField(from interface{}, field *Field) interface{} {
7777 v = reflect .Indirect (v )
7878 kind = v .Kind ()
7979 }
80- if kind == reflect .Struct {
81- // We can use v.FieldByIndex here, but it will panic if the field
82- // is not exists. And we need to recover() to generate a more
83- // user-friendly error message.
84- // Also, our fieldByIndex() function is slightly faster than the
85- // v.FieldByIndex() function as we don't need to verify what a field
86- // is a struct as we already did it on compilation step.
87- value := fieldByIndex (v , field .Index )
88- if value .IsValid () {
89- return value .Interface ()
90- }
80+ // We can use v.FieldByIndex here, but it will panic if the field
81+ // is not exists. And we need to recover() to generate a more
82+ // user-friendly error message.
83+ // Also, our fieldByIndex() function is slightly faster than the
84+ // v.FieldByIndex() function as we don't need to verify what a field
85+ // is a struct as we already did it on compilation step.
86+ value := fieldByIndex (v , field .Index )
87+ if value .IsValid () {
88+ return value .Interface ()
9189 }
9290 }
9391 panic (fmt .Sprintf ("cannot get %v from %T" , field .Path , from ))
You can’t perform that action at this time.
0 commit comments