Skip to content
New issue

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

服务器代码有误,会造成客户端接收不到返回值。 #10

Open
CppToGo opened this issue Mar 1, 2019 · 0 comments
Open

Comments

@CppToGo
Copy link

CppToGo commented Mar 1, 2019

在我的机器上运行,我的客户端接收不到返回值。
经过排查后发现,是服务器该端代码导致的
resp = &pb.Response{Created: true, Consignment: consignment}
局部指针赋值给参数指针,在go函数返回的时候,参数指针所指向的地址会变为原地址(即传入时所指向的地址),由此引发局部指针的复制丢失。客户端收到的返回值永远都是一个内容为空的Response结构体指针。
所以只能改为
resp.Created = true
resp.Consignment = consignment
这样赋值,才会运行正常

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant