dongpan2788 2018-02-17 15:24
浏览 396
已采纳

无法在Go lang中将int32 protobuf分配给int [重复]

This question already has an answer here:

So in my protobuf I have a message object

message HelloReply {
    int32 response = 1;
}

And I try to assign the response to a variable

var resp = 0
resp = helloReply.Response

I got an error saying

cannot use helloReply.Response (type int32) as type int in assignment

P.S I'm really new to Go and Protobuf. I'm sorry if this is too basic. I already search for the solution but I think I can't find the right keyword. So I really need your help guys :(

</div>
  • 写回答

1条回答 默认 最新

  • duanlanzhi5509 2018-02-17 15:35
    关注

    Create resp variable of int32 type and assign helloReply.Response to resp variable. Like this

    var resp int32
    resp = helloReply.Response
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 如何通过代码传输视频到亚马逊平台
  • ¥15 php查询mysql数据库并显示至下拉列表中
  • ¥15 freertos下使用外部中断失效
  • ¥15 输入的char字符转为int类型,不是对应的ascall码,如何才能使之转换为对应ascall码?或者使输入的char字符可以正常与其他字符比较?
  • ¥15 devserver配置完 启动服务 无法访问static上的资源
  • ¥15 解决websocket跟c#客户端通信
  • ¥30 Python调用dll文件输出Nan重置dll状态
  • ¥15 浮动div的高度控制问题。
  • ¥66 换电脑后应用程序报错
  • ¥50 array数据同步问题