func visitField(ctx *visitorContext, val interface{}) bool {
	if val == nil {
		return false
	}
	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
}
// 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.
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.
// 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 {
	if val == nil {
		return false
	}
	typ := reflect.TypeOf(val)
	v := reflect.ValueOf(val)
	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)
	}
	return false
}
func visitField ( ctx * visitorContext , val interface { } ) bool { if val == nil { return false } typ := reflect . TypeOf ( val ) v := reflect . ValueOf ( val ) 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 ) } return false }
visitField invokes ctx.structVisitor(val) if v is a struct and returns back
the visitor's result.
visitField invokes ctx . structVisitor ( val ) if v is a struct and returns back the visitor ' s result .
// De-reference pointers // v is not a struct or something we can iterate to reach a struct