Fix name of fields 82/7082/1
authorLukas Macko <lmacko@cisco.com>
Fri, 9 Jun 2017 11:16:57 +0000 (13:16 +0200)
committerLukas Macko <lmacko@cisco.com>
Fri, 9 Jun 2017 11:22:08 +0000 (13:22 +0200)
Change-Id: I9dd1ab75c3619e6ddc6cf07491491b556b96fb20
Signed-off-by: Lukas Macko <lmacko@cisco.com>
adapter/mock/binapi/binapi_reflect.go

index ee89909..1aeec1d 100644 (file)
@@ -20,18 +20,18 @@ import (
        "reflect"
 )
 
-const swIfIndexName = "swIfIndex"
-const retvalName = "retval"
+const swIfIndexName = "SwIfIndex"
+const retvalName = "Retval"
 const replySuffix = "_reply"
 
 // findFieldOfType finds the field specified by its name in provided message defined as reflect.Type data type.
 func findFieldOfType(reply reflect.Type, fieldName string) (reflect.StructField, bool) {
+       for reply.Kind() == reflect.Ptr {
+               reply = reply.Elem()
+       }
        if reply.Kind() == reflect.Struct {
                field, found := reply.FieldByName(fieldName)
                return field, found
-       } else if reply.Kind() == reflect.Ptr && reply.Elem().Kind() == reflect.Struct {
-               field, found := reply.Elem().FieldByName(fieldName)
-               return field, found
        }
        return reflect.StructField{}, false
 }