1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 17:46:58 -05:00

switch to errgroup

This commit is contained in:
Darien Raymond 2018-12-06 10:22:14 +01:00
parent c89183e6b3
commit cf1705267e
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -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)
}
}()