From 3b0ef425b6e3c45a85eab47bb73b980106c58857 Mon Sep 17 00:00:00 2001 From: lpxxn Date: Thu, 27 Jun 2019 13:06:53 +0800 Subject: [PATCH] pass parameter to anonymous function --- client/grpc/grpc.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/grpc/grpc.go b/client/grpc/grpc.go index df4163c7..b067d826 100644 --- a/client/grpc/grpc.go +++ b/client/grpc/grpc.go @@ -372,9 +372,9 @@ func (g *grpcClient) Call(ctx context.Context, req client.Request, rsp interface var gerr error for i := 0; i <= callOpts.Retries; i++ { - go func() { + go func(i int) { ch <- call(i) - }() + }(i) select { case <-ctx.Done(): @@ -455,10 +455,10 @@ func (g *grpcClient) Stream(ctx context.Context, req client.Request, opts ...cli var grr error for i := 0; i <= callOpts.Retries; i++ { - go func() { + go func(i int) { s, err := call(i) ch <- response{s, err} - }() + }(i) select { case <-ctx.Done():