Skip to content

Commit dc13aef

Browse files
committed
make linter happy
1 parent c80f50b commit dc13aef

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

redis.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,8 @@ func (c *baseClient) initConn(ctx context.Context, cn *pool.Conn) error {
401401
// Another goroutine is initializing - WAIT for it to complete
402402
// Use a context with timeout = min(remaining command timeout, DialTimeout)
403403
// This prevents waiting too long while respecting the caller's deadline
404-
waitCtx := ctx
404+
var waitCtx context.Context
405+
var cancel context.CancelFunc
405406
dialTimeout := c.opt.DialTimeout
406407

407408
if cmdDeadline, hasCmdDeadline := ctx.Deadline(); hasCmdDeadline {
@@ -413,13 +414,11 @@ func (c *baseClient) initConn(ctx context.Context, cn *pool.Conn) error {
413414
waitCtx = ctx
414415
} else {
415416
// DialTimeout is shorter, cap the wait at DialTimeout
416-
var cancel context.CancelFunc
417417
waitCtx, cancel = context.WithTimeout(ctx, dialTimeout)
418418
defer cancel()
419419
}
420420
} else {
421421
// No command deadline, use DialTimeout to prevent waiting indefinitely
422-
var cancel context.CancelFunc
423422
waitCtx, cancel = context.WithTimeout(ctx, dialTimeout)
424423
defer cancel()
425424
}

0 commit comments

Comments
 (0)