Skip to content

Commit 6ce2da4

Browse files
committed
all: update to latest in b5d812f8
This merges in the following upstream PRs: * #797: ptypes: More cleanly construct a Timestamp * #796: ptypes: Avoid assuming time.Duration is nanoseconds * #805: proto: remove test dependency on experimental packages * #808: Delete the conformance test Change-Id: I104189682bbc0a18e3d8460e57f9fcb45f1f4a46 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/166521 Reviewed-by: Herbie Ong <[email protected]>
1 parent 22c36ed commit 6ce2da4

File tree

7 files changed

+21
-31
lines changed

7 files changed

+21
-31
lines changed

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ test:
1111
go test ./... ./protoc-gen-go/testdata
1212
go test -tags purego ./... ./protoc-gen-go/testdata
1313
go build ./protoc-gen-go/testdata/grpc/grpc.pb.go
14-
make -C conformance test
1514

1615
clean:
1716
go clean ./...

go.mod

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
module github.com/golang/protobuf
22

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

go.sum

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@ github.com/golang/protobuf/v2 v2.0.0-20181127193627-d7e97bc71bcb/go.mod h1:MgUD+
44
github.com/google/go-cmp v0.2.1-0.20181101181452-745b8ec83783 h1:wVZ6laEGf86tNDTpR5mxFyFIclJJiXCxuJhcQKnsOHk=
55
github.com/google/go-cmp v0.2.1-0.20181101181452-745b8ec83783/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
66
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=
107
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=
119
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=
1510
google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=

proto/extensions_test.go

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import (
1111
"reflect"
1212
"sort"
1313
"strings"
14+
"sync"
1415
"testing"
1516

1617
"github.com/golang/protobuf/proto"
1718
pb "github.com/golang/protobuf/proto/test_proto"
18-
"golang.org/x/sync/errgroup"
1919
)
2020

2121
func TestGetExtensionsWithMissingExtensions(t *testing.T) {
@@ -644,18 +644,22 @@ func TestMarshalRace(t *testing.T) {
644644
// GetExtension will decode it lazily. Make sure this does
645645
// not race against Marshal.
646646

647-
var g errgroup.Group
647+
wg := sync.WaitGroup{}
648+
errs := make(chan error, 3)
648649
for n := 3; n > 0; n-- {
649-
g.Go(func() error {
650+
wg.Add(1)
651+
go func() {
652+
defer wg.Done()
650653
_, 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+
}
660664
}
661665
}

ptypes/duration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func Duration(p *durpb.Duration) (time.Duration, error) {
5555
return 0, fmt.Errorf("duration: %v is out of range for time.Duration", p)
5656
}
5757
if p.Nanos != 0 {
58-
d += time.Duration(p.Nanos)
58+
d += time.Duration(p.Nanos) * time.Nanosecond
5959
if (d < 0) != (p.Nanos < 0) {
6060
return 0, fmt.Errorf("duration: %v is out of range for time.Duration", p)
6161
}

ptypes/timestamp.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,9 @@ func TimestampNow() *tspb.Timestamp {
8484
// TimestampProto converts the time.Time to a google.protobuf.Timestamp proto.
8585
// It returns an error if the resulting Timestamp is invalid.
8686
func TimestampProto(t time.Time) (*tspb.Timestamp, error) {
87-
seconds := t.Unix()
88-
nanos := int32(t.Sub(time.Unix(seconds, 0)))
8987
ts := &tspb.Timestamp{
90-
Seconds: seconds,
91-
Nanos: nanos,
88+
Seconds: t.Unix(),
89+
Nanos: int32(t.Nanosecond()),
9290
}
9391
if err := validateTimestamp(ts); err != nil {
9492
return nil, err

regenerate.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ fi
1717

1818
# Generate various test protos.
1919
PROTO_DIRS=(
20-
conformance/internal/conformance_proto
2120
jsonpb/jsonpb_test_proto
2221
proto
2322
protoc-gen-go/testdata

0 commit comments

Comments
 (0)