From 181419256d42885d1b8624a55fc054acd763c814 Mon Sep 17 00:00:00 2001 From: Zeming YU Date: Tue, 6 Aug 2019 13:31:32 -0700 Subject: [PATCH] integration: fix a data race about `err` don't share `err` between goroutines --- clientv3/integration/metrics_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/clientv3/integration/metrics_test.go b/clientv3/integration/metrics_test.go index ba02e3514..c7dbc0488 100644 --- a/clientv3/integration/metrics_test.go +++ b/clientv3/integration/metrics_test.go @@ -41,12 +41,13 @@ func TestV3ClientMetrics(t *testing.T) { var ( addr = "localhost:27989" ln net.Listener - err error ) // listen for all Prometheus metrics donec := make(chan struct{}) go func() { + var err error + defer close(donec) srv := &http.Server{Handler: promhttp.Handler()} @@ -87,7 +88,7 @@ func TestV3ClientMetrics(t *testing.T) { pBefore := sumCountersForMetricAndLabels(t, url, "grpc_client_started_total", "Put", "unary") - _, err = cli.Put(context.Background(), "foo", "bar") + _, err := cli.Put(context.Background(), "foo", "bar") if err != nil { t.Errorf("Error putting value in key store") }