@ -76,6 +76,14 @@ func Walk(data, walker interface{}) (err error) {
}
func walk ( v reflect . Value , w interface { } ) ( err error ) {
// We preserve the original value here because if it is an interface
// type, we want to pass that directly into the walkPrimitive, so that
// we can set it.
originalV := v
if v . Kind ( ) == reflect . Interface {
v = v . Elem ( )
}
// Determine if we're receiving a pointer and if so notify the walker.
pointer := false
if v . Kind ( ) == reflect . Ptr {
@ -96,14 +104,6 @@ func walk(v reflect.Value, w interface{}) (err error) {
} ( )
}
// We preserve the original value here because if it is an interface
// type, we want to pass that directly into the walkPrimitive, so that
// we can set it.
originalV := v
if v . Kind ( ) == reflect . Interface {
v = v . Elem ( )
}
k := v . Kind ( )
if k >= reflect . Int && k <= reflect . Complex128 {
k = reflect . Int
@ -143,12 +143,6 @@ func walkMap(v reflect.Value, w interface{}) error {
for _ , k := range v . MapKeys ( ) {
kv := v . MapIndex ( k )
// if the map value type is an interface, we need to extract the Elem
// for the next call to walk
if kv . Kind ( ) == reflect . Interface {
kv = kv . Elem ( )
}
if mw , ok := w . ( MapWalker ) ; ok {
if err := mw . MapElem ( v , k , kv ) ; err != nil {
return err
@ -208,12 +202,6 @@ func walkSlice(v reflect.Value, w interface{}) (err error) {
for i := 0 ; i < v . Len ( ) ; i ++ {
elem := v . Index ( i )
// if the value type is an interface, we need to extract the Elem
// for the next call to walk
if elem . Kind ( ) == reflect . Interface {
elem = elem . Elem ( )
}
if sw , ok := w . ( SliceWalker ) ; ok {
if err := sw . SliceElem ( i , elem ) ; err != nil {
return err