From e13e329abc7141848277a223d94e481fa9671587 Mon Sep 17 00:00:00 2001 From: Astone Date: Tue, 3 Dec 2019 15:25:58 +0800 Subject: [PATCH] improve code quality --- grpc.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/grpc.go b/grpc.go index 0fa3d0f..c365d33 100644 --- a/grpc.go +++ b/grpc.go @@ -222,7 +222,9 @@ func (g *grpcServer) handler(srv interface{}, stream grpc.ServerStream) error { // set the timeout if we have it if len(to) > 0 { if n, err := strconv.ParseUint(to, 10, 64); err == nil { - ctx, _ = context.WithTimeout(ctx, time.Duration(n)) + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, time.Duration(n)) + defer cancel() } }