Skip to content

Commit 9bfdcee

Browse files
alexrudddsnet
authored andcommitted
proto: remove test dependency on experimental packages (#805)
Removes two go mod dependencies on golang.org/x/sync and indirectly on golang.org/x/net. These were being used to provide an errgroup.Group to collate errors in a test. This PR provides the same functionality but using sync.WaitGroup.
1 parent c823c79 commit 9bfdcee

File tree

3 files changed

+17
-21
lines changed

3 files changed

+17
-21
lines changed

go.mod

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
module github.com/golang/protobuf
22

3-
require (
4-
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd // indirect
5-
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f
6-
google.golang.org/genproto v0.0.0-20180831171423-11092d34479b
7-
)
3+
require google.golang.org/genproto v0.0.0-20180831171423-11092d34479b

go.sum

-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
1-
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA=
2-
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
3-
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA=
4-
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
51
google.golang.org/genproto v0.0.0-20180831171423-11092d34479b h1:lohp5blsw53GBXtLyLNaTXPXS9pJ1tiTw61ZHUoE9Qw=
62
google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=

proto/extensions_test.go

+16-12
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ import (
3838
"reflect"
3939
"sort"
4040
"strings"
41+
"sync"
4142
"testing"
4243

4344
"github.com/golang/protobuf/proto"
4445
pb "github.com/golang/protobuf/proto/test_proto"
45-
"golang.org/x/sync/errgroup"
4646
)
4747

4848
func TestGetExtensionsWithMissingExtensions(t *testing.T) {
@@ -671,18 +671,22 @@ func TestMarshalRace(t *testing.T) {
671671
// GetExtension will decode it lazily. Make sure this does
672672
// not race against Marshal.
673673

674-
var g errgroup.Group
674+
wg := sync.WaitGroup{}
675+
errs := make(chan error, 3)
675676
for n := 3; n > 0; n-- {
676-
g.Go(func() error {
677+
wg.Add(1)
678+
go func() {
679+
defer wg.Done()
677680
_, err := proto.Marshal(m)
678-
return err
679-
})
680-
g.Go(func() error {
681-
_, err := proto.GetExtension(m, pb.E_Ext_More)
682-
return err
683-
})
684-
}
685-
if err := g.Wait(); err != nil {
686-
t.Fatal(err)
681+
errs <- err
682+
}()
683+
}
684+
wg.Wait()
685+
close(errs)
686+
687+
for err = range errs {
688+
if err != nil {
689+
t.Fatal(err)
690+
}
687691
}
688692
}

0 commit comments

Comments
 (0)