日常开发错误
错误1
错误:
grpc客户端调用服务端时,报如下错误:
grpc panic: runtime error: invalid memory address or nil pointer dereference
原因:
可能使用的调用方法是老版本。
解决:
使用如下方法连接服务端即可
conn, err := grpc.Dial("localhost:"+port, grpc.WithTransportCredentials(insecure.NewCredentials()))
友情提示:
开发时,吧所有错误都判断一下,方便根据提示信息定位问题。不要偷懒,使用“_”忽略err。