From 98078875c5a5a9b0cbfd939125e7227509d7bb4b Mon Sep 17 00:00:00 2001 From: ning <710leo@gmail.com> Date: Thu, 20 Oct 2022 11:59:13 +0800 Subject: [PATCH] fix rpc client panic --- net/gobrpc/client.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/gobrpc/client.go b/net/gobrpc/client.go index 240c8cc..bebc01c 100644 --- a/net/gobrpc/client.go +++ b/net/gobrpc/client.go @@ -44,6 +44,10 @@ func (c *RPCClient) Call(method string, args interface{}, reply interface{}, cal done := make(chan error, 1) go func() { + if c.rpcClient == nil { + done <- fmt.Errorf("rpc client is nil") + return + } err := c.rpcClient.Call(method, args, reply) done <- err }() @@ -59,6 +63,4 @@ func (c *RPCClient) Call(method string, args interface{}, reply interface{}, cal case err := <-done: return err } - - return nil }