marsmay commented on issue #284:
URL: 
https://github.com/apache/dubbo-go-hessian2/issues/284#issuecomment-948435091


   > 你试试统一用
   > 
   > ```go
   > type MerchantResponse struct {
   >     Code    string
   >     Message string
   >     Data    interface{}
   > }
   > 
   > func (MerchantResponse) JavaClassName() string {
   >     return "com.xxx.common.Result"
   > }
   > ```
   > 
   > 再通过反射处理Data
   > 
   > ```go
   > func req() {
   > res, err := api.List()
   > 
   > switch unpackType(reflect.TypeOf(res)) {
   > case reflect.Slice:
   >   if res0, ok := res.([]interface{}); ok {
   >     for _, v := range res0 {
   >       item := decode(v)
   >     }
   >   }
   > default:
   >   item := decode(res)
   > }
   > }
   > 
   > func decode(o interface{}) *Merchant {
   >   resJson, err := json.Marshal(o)
   >   result := &Merchant{}
   >   _ =  json.Unmarshal(resJson, result)
   >   return result
   > }
   > ```
   > 
   > @marsmay
   
   我感觉可能是遇到了你之前提的 #1454 这个问题,哎,现在要 java 调用方修改比较困难,实在不行只能我改 golang provider 
的返回了,不用范型返回就行。golang consumer 调 java provider 还是可以用范型的。
   


-- 
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.

To unsubscribe, e-mail: [email protected]

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