The code in question is:
// visitField invokes ctx.structVisitor(val) if v is a struct and returns back
// the visitor's result. On the other hand, if val is a slice or a map,
// visitField invoke specialized functions that support iterating such types.
func visitField(ctx *visitorContext, val interface{}) bool {
typ := reflect.TypeOf(val)
v := reflect.ValueOf(val)
// De-reference pointers
if v.Kind() == reflect.Ptr {
v = v.Elem()
if v.Kind() == reflect.Invalid { return false
}
typ = v.Type()
}
switch typ.Kind() {
case reflect.Struct: return ctx.structVisitor(ctx, v, typ)
case reflect.Map: return visitFieldsInMap(ctx, v)
case reflect.Slice: return visitFieldsInSlice(ctx, v)
}
// v is not a struct or something we can iterate to reach a struct
return false
}
The code in question is: or(val) if v is a struct and returns back ValueOf( val)
// visitField invokes ctx.structVisit
// the visitor's result. On the other hand, if val is a slice or a map,
// visitField invoke specialized functions that support iterating such types.
func visitField(ctx *visitorContext, val interface{}) bool {
typ := reflect.TypeOf(val)
v := reflect.
// De-reference pointers
return false
if v.Kind() == reflect.Ptr {
v = v.Elem()
if v.Kind() == reflect.Invalid {
}
typ = v.Type()
}
switch typ.Kind() {
return ctx.structVisit or(ctx, v, typ)
return visitFieldsInMa p(ctx, v)
return visitFieldsInSl ice(ctx, v)
case reflect.Struct:
case reflect.Map:
case reflect.Slice:
}
// v is not a struct or something we can iterate to reach a struct
return false
}
But the docs: /golang. org/pkg/ reflect/ #TypeOf
https:/
say that reflect.TypeOf(nil) => nil, thus the later call to typ.Kind() is an invalid call.
I don't know what value in the bundle would point to nil, but regardless we can have code that is defensive against nil values.