From 36ae71ab5245009458e483817b78d850a33ee709 Mon Sep 17 00:00:00 2001 From: Vladimir Samoylov Date: Thu, 7 Nov 2024 11:48:19 +0700 Subject: [PATCH] fix golang linter suggestions --- grpc_healthcheck.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/grpc_healthcheck.go b/grpc_healthcheck.go index 4048287..a0ae8f2 100644 --- a/grpc_healthcheck.go +++ b/grpc_healthcheck.go @@ -50,7 +50,7 @@ func grpchealthprobe(flAddr string) (string, int) { opts := []grpc.DialOption{ grpc.WithUserAgent(flUserAgent), - grpc.WithBlock(), + grpc.WithTimeout(flConnTimeout), // Add connection timeout } if flTLS && flSPIFFE { log.Printf("-tls and -spiffe are mutually incompatible") @@ -98,9 +98,7 @@ func grpchealthprobe(flAddr string) (string, int) { log.Print("establishing connection") } connStart := time.Now() - dialCtx, dialCancel := context.WithTimeout(ctx, flConnTimeout) - defer dialCancel() - conn, err := grpc.DialContext(dialCtx, flAddr, opts...) + conn, err := grpc.Dial(flAddr, opts...) if err != nil { if err == context.DeadlineExceeded { log.Printf("timeout: failed to connect service %q within %v", flAddr, flConnTimeout)