From cf1705267e2268fcafd66941ff3cdf877871d51b Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Thu, 6 Dec 2018 10:22:14 +0100 Subject: [PATCH] switch to errgroup --- common/buf/readv_test.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/common/buf/readv_test.go b/common/buf/readv_test.go index 7c4056d8..13ea35f0 100644 --- a/common/buf/readv_test.go +++ b/common/buf/readv_test.go @@ -7,6 +7,7 @@ import ( "net" "testing" + "golang.org/x/sync/errgroup" "v2ray.com/core/common" . "v2ray.com/core/common/buf" "v2ray.com/core/common/compare" @@ -31,12 +32,17 @@ func TestReadvReader(t *testing.T) { data := make([]byte, 8192) common.Must2(rand.Read(data)) - go func() { + var errg errgroup.Group + errg.Go(func() error { writer := NewWriter(conn) mb := MergeBytes(nil, data) - if err := writer.WriteMultiBuffer(mb); err != nil { - t.Fatal("failed to write data: ", err) + return writer.WriteMultiBuffer(mb) + }) + + defer func() { + if err := errg.Wait(); err != nil { + t.Error(err) } }()