From 2927d060a8a89036a99fe51cac702efd1224f4d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oscar=20S=C3=B6derlund?= Date: Tue, 29 Dec 2020 10:22:38 +0100 Subject: [PATCH] chore: remove dependency on /x/sync For a public repo it's better with one less dependency than a slightly simpler test in this case. --- go.mod | 1 - go.sum | 2 -- receiver_test.go | 16 ++++++++++------ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index dd76ad8..abd7a5b 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,5 @@ go 1.14 require ( golang.org/x/net v0.0.0-20201224014010-6772e930b67b - golang.org/x/sync v0.0.0-20201207232520-09787c993a3a gotest.tools/v3 v3.0.3 ) diff --git a/go.sum b/go.sum index 6d4e30a..bc07893 100644 --- a/go.sum +++ b/go.sum @@ -9,8 +9,6 @@ golang.org/x/net v0.0.0-20201224014010-6772e930b67b h1:iFwSg7t5GZmB/Q5TjiEAsdoLD golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201207232520-09787c993a3a h1:DcqTD9SDLc+1P/r1EmRBwnVsrOwW+kk2vWf9n+1sGhs= -golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw= diff --git a/receiver_test.go b/receiver_test.go index 794fc01..05dad9b 100644 --- a/receiver_test.go +++ b/receiver_test.go @@ -3,11 +3,11 @@ package vlp16 import ( "context" "net" + "sync" "testing" "time" "golang.org/x/net/nettest" - "golang.org/x/sync/errgroup" "gotest.tools/v3/assert" ) @@ -18,16 +18,20 @@ func TestClient_Receive(t *testing.T) { addr := getFreeAddress(t) rx, err := ListenUDP(ctx, addr) assert.NilError(t, err) - var g errgroup.Group - g.Go(func() error { - return rx.Receive(ctx) - }) + var g sync.WaitGroup + g.Add(1) + go func() { + defer g.Done() + if err := rx.Receive(ctx); err != nil { + t.Error(err) + } + }() conn, err := net.Dial("udp4", addr) assert.NilError(t, err) _, err = conn.Write(exampleRawPacket(t)[:]) assert.NilError(t, err) assert.NilError(t, conn.Close()) - assert.NilError(t, g.Wait()) + g.Wait() assert.DeepEqual(t, exampleRawPacket(t), rx.RawPacket()) assert.DeepEqual(t, examplePacket(), rx.Packet()) }