zonghaishang commented on a change in pull request #201:
URL: https://github.com/apache/dubbo-go-hessian2/pull/201#discussion_r437847979



##########
File path: codec.go
##########
@@ -422,6 +420,59 @@ func SetSlice(dest reflect.Value, objects interface{}) 
error {
        return nil
 }
 
+// SetMap set value(map[interface{}]interface{}) into map[T]T
+func SetMap(dest reflect.Value, objects interface{}) error {
+       if objects == nil {
+               return nil
+       }
+
+       src := objects.(map[interface{}]interface{})
+       srcv := reflect.ValueOf(src)
+
+       dest = UnpackPtrValue(dest)
+       destTyp := UnpackPtrType(dest.Type())
+       if dest.IsNil() {
+               dest.Set(reflect.MakeMap(destTyp))
+       }
+       for _, keyv := range srcv.MapKeys() {
+               dest.SetMapIndex(reflect.ValueOf(keyv.Interface()), 
reflect.ValueOf(srcv.MapIndex(keyv).Interface()))
+       }
+
+       return nil

Review comment:
       这里为啥直接 return  nil ? 后面逻辑不走了 ?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to