无法在 Go lang 中将 int32 protobuf 分配给 int
Can't assign int32 protobuf to int in Go lang
所以在我的 protobuf 中有一个消息对象
message HelloReply {
int32 response = 1;
}
然后我尝试将响应分配给变量
var resp = 0
resp = helloReply.Response
我收到一条错误消息
cannot use helloReply.Response (type int32) as type int in assignment
P.S 我是 Go 和 Protobuf 的新手。如果这太基本了,我很抱歉。我已经在寻找解决方案,但我想我找不到合适的关键字。所以我真的需要你们的帮助:(
创建resp
int32 类型的变量并将helloReply.Response
赋值给resp 变量。像这样
var resp int32
resp = helloReply.Response
所以在我的 protobuf 中有一个消息对象
message HelloReply {
int32 response = 1;
}
然后我尝试将响应分配给变量
var resp = 0
resp = helloReply.Response
我收到一条错误消息
cannot use helloReply.Response (type int32) as type int in assignment
P.S 我是 Go 和 Protobuf 的新手。如果这太基本了,我很抱歉。我已经在寻找解决方案,但我想我找不到合适的关键字。所以我真的需要你们的帮助:(
创建resp
int32 类型的变量并将helloReply.Response
赋值给resp 变量。像这样
var resp int32
resp = helloReply.Response