We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在我的机器上运行,我的客户端接收不到返回值。 经过排查后发现,是服务器该端代码导致的 resp = &pb.Response{Created: true, Consignment: consignment} 局部指针赋值给参数指针,在go函数返回的时候,参数指针所指向的地址会变为原地址(即传入时所指向的地址),由此引发局部指针的复制丢失。客户端收到的返回值永远都是一个内容为空的Response结构体指针。 所以只能改为 resp.Created = true resp.Consignment = consignment 这样赋值,才会运行正常
resp = &pb.Response{Created: true, Consignment: consignment}
resp.Created = true
resp.Consignment = consignment
The text was updated successfully, but these errors were encountered:
No branches or pull requests
在我的机器上运行,我的客户端接收不到返回值。
经过排查后发现,是服务器该端代码导致的
resp = &pb.Response{Created: true, Consignment: consignment}
局部指针赋值给参数指针,在go函数返回的时候,参数指针所指向的地址会变为原地址(即传入时所指向的地址),由此引发局部指针的复制丢失。客户端收到的返回值永远都是一个内容为空的Response结构体指针。
所以只能改为
resp.Created = true
resp.Consignment = consignment
这样赋值,才会运行正常
The text was updated successfully, but these errors were encountered: