File tree Expand file tree Collapse file tree 7 files changed +21
-31
lines changed Expand file tree Collapse file tree 7 files changed +21
-31
lines changed Original file line number Diff line number Diff line change 11
11
go test ./... ./protoc-gen-go/testdata
12
12
go test -tags purego ./... ./protoc-gen-go/testdata
13
13
go build ./protoc-gen-go/testdata/grpc/grpc.pb.go
14
- make -C conformance test
15
14
16
15
clean :
17
16
go clean ./...
Original file line number Diff line number Diff line change 1
1
module github.com/golang/protobuf
2
2
3
- require (
4
- github.com/golang/protobuf/v2 v2.0.0-20181127193627-d7e97bc71bcb
5
- golang.org/x/net v0.0.0-20180926154720-4dfa2610cdf3 // indirect
6
- golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f
7
- golang.org/x/tools v0.0.0-20180928181343-b3c0be4c978b // indirect
8
- )
3
+ require github.com/golang/protobuf/v2 v2.0.0-20181127193627-d7e97bc71bcb
Original file line number Diff line number Diff line change @@ -4,12 +4,7 @@ github.com/golang/protobuf/v2 v2.0.0-20181127193627-d7e97bc71bcb/go.mod h1:MgUD+
4
4
github.com/google/go-cmp v0.2.1-0.20181101181452-745b8ec83783 h1:wVZ6laEGf86tNDTpR5mxFyFIclJJiXCxuJhcQKnsOHk =
5
5
github.com/google/go-cmp v0.2.1-0.20181101181452-745b8ec83783 /go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M =
6
6
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd /go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4 =
7
- golang.org/x/net v0.0.0-20180926154720-4dfa2610cdf3 h1:dgd4x4kJt7G4k4m93AYLzM8Ni6h2qLTfh9n9vXJT3/0 =
8
- golang.org/x/net v0.0.0-20180926154720-4dfa2610cdf3 /go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4 =
9
- golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA =
10
7
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f /go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM =
8
+ golang.org/x/tools v0.0.0-20180904205237-0aa4b8830f48 h1:PIz+xUHW4G/jqfFWeKhQ96ZV/t2HDsXfWj923rV0bZY =
11
9
golang.org/x/tools v0.0.0-20180904205237-0aa4b8830f48 /go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ =
12
- golang.org/x/tools v0.0.0-20180928181343-b3c0be4c978b h1:hjfKpJoTfQ2QXKPX9eCDFBZ0t9sDrZL/viAgrN962TQ =
13
- golang.org/x/tools v0.0.0-20180928181343-b3c0be4c978b /go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ =
14
- google.golang.org/genproto v0.0.0-20180831171423-11092d34479b h1:lohp5blsw53GBXtLyLNaTXPXS9pJ1tiTw61ZHUoE9Qw =
15
10
google.golang.org/genproto v0.0.0-20180831171423-11092d34479b /go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc =
Original file line number Diff line number Diff line change @@ -11,11 +11,11 @@ import (
11
11
"reflect"
12
12
"sort"
13
13
"strings"
14
+ "sync"
14
15
"testing"
15
16
16
17
"github.com/golang/protobuf/proto"
17
18
pb "github.com/golang/protobuf/proto/test_proto"
18
- "golang.org/x/sync/errgroup"
19
19
)
20
20
21
21
func TestGetExtensionsWithMissingExtensions (t * testing.T ) {
@@ -644,18 +644,22 @@ func TestMarshalRace(t *testing.T) {
644
644
// GetExtension will decode it lazily. Make sure this does
645
645
// not race against Marshal.
646
646
647
- var g errgroup.Group
647
+ wg := sync.WaitGroup {}
648
+ errs := make (chan error , 3 )
648
649
for n := 3 ; n > 0 ; n -- {
649
- g .Go (func () error {
650
+ wg .Add (1 )
651
+ go func () {
652
+ defer wg .Done ()
650
653
_ , err := proto .Marshal (m )
651
- return err
652
- })
653
- g .Go (func () error {
654
- _ , err := proto .GetExtension (m , pb .E_Ext_More )
655
- return err
656
- })
657
- }
658
- if err := g .Wait (); err != nil {
659
- t .Fatal (err )
654
+ errs <- err
655
+ }()
656
+ }
657
+ wg .Wait ()
658
+ close (errs )
659
+
660
+ for err = range errs {
661
+ if err != nil {
662
+ t .Fatal (err )
663
+ }
660
664
}
661
665
}
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ func Duration(p *durpb.Duration) (time.Duration, error) {
55
55
return 0 , fmt .Errorf ("duration: %v is out of range for time.Duration" , p )
56
56
}
57
57
if p .Nanos != 0 {
58
- d += time .Duration (p .Nanos )
58
+ d += time .Duration (p .Nanos ) * time . Nanosecond
59
59
if (d < 0 ) != (p .Nanos < 0 ) {
60
60
return 0 , fmt .Errorf ("duration: %v is out of range for time.Duration" , p )
61
61
}
Original file line number Diff line number Diff line change @@ -84,11 +84,9 @@ func TimestampNow() *tspb.Timestamp {
84
84
// TimestampProto converts the time.Time to a google.protobuf.Timestamp proto.
85
85
// It returns an error if the resulting Timestamp is invalid.
86
86
func TimestampProto (t time.Time ) (* tspb.Timestamp , error ) {
87
- seconds := t .Unix ()
88
- nanos := int32 (t .Sub (time .Unix (seconds , 0 )))
89
87
ts := & tspb.Timestamp {
90
- Seconds : seconds ,
91
- Nanos : nanos ,
88
+ Seconds : t . Unix () ,
89
+ Nanos : int32 ( t . Nanosecond ()) ,
92
90
}
93
91
if err := validateTimestamp (ts ); err != nil {
94
92
return nil , err
Original file line number Diff line number Diff line change 17
17
18
18
# Generate various test protos.
19
19
PROTO_DIRS=(
20
- conformance/internal/conformance_proto
21
20
jsonpb/jsonpb_test_proto
22
21
proto
23
22
protoc-gen-go/testdata
You can’t perform that action at this time.
0 commit comments