diff --git a/Go/source/regworkerid/reghelper.go b/Go/source/regworkerid/reghelper.go index 20cfab4..64a472a 100644 --- a/Go/source/regworkerid/reghelper.go +++ b/Go/source/regworkerid/reghelper.go @@ -66,6 +66,7 @@ func RegisterWorkerId(ip string, port int, password string, maxWorkerId int) int _ConnString = ip + ":" + strconv.Itoa(port) _Password = password _client = newRedisClient() + defer _client.Close() _, err := _client.Ping(_ctx).Result() if err != nil { @@ -74,7 +75,6 @@ func RegisterWorkerId(ip string, port int, password string, maxWorkerId int) int if _Log { fmt.Println("init redis ok") } - defer _client.Close() } _loopCount = 0