Skip to content

Commit ba00afd

Browse files
committed
proto: fix interactions with v2 extensions
Update to the latest version of google.golang.org/protobuf. https://golang.org/cl/192458 changed the Go representation of repeated extension fields to []T (from *[]T). Make the corresponding update here. Change-Id: Ia67e3899069d83f145569f01635f4ae3d9e664b8 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/204798 Reviewed-by: Joe Tsai <[email protected]>
1 parent 62f67f1 commit ba00afd

File tree

3 files changed

+5
-19
lines changed

3 files changed

+5
-19
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ module github.com/golang/protobuf
22

33
go 1.9
44

5-
require google.golang.org/protobuf v0.0.0-20190828183429-79bfdbe45be2
5+
require google.golang.org/protobuf v0.0.0-20191031162342-c826885a2abe

go.sum

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ github.com/golang/protobuf v1.2.1-0.20190620192300-1ee46dfd80dd/go.mod h1:+CMAsi
99
github.com/golang/protobuf v1.2.1-0.20190806214225-7037721e6de0/go.mod h1:tDQPRlaHYu9yt1wPgdx85inRiLvUCuJZXsYjC0mwc1c=
1010
github.com/golang/protobuf v1.2.1-0.20190820204156-2da1b93405dd/go.mod h1:x87I3ou7ehf/yR6iQ88MkyDogdxXN04TELJ7HVy7V7I=
1111
github.com/golang/protobuf v1.2.1-0.20190820213554-ae1d65bc5435/go.mod h1:k7dGkiTZ3rjVDhKSpGt+x1zDzAePJk4jdhoBwIkQgBo=
12+
github.com/golang/protobuf v1.2.1-0.20191004062209-62f67f1ea9df/go.mod h1:o4el5ABfDjqFlwwvAq2OIgAPeNXQYUkhtrjNPXy6T6I=
1213
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
1314
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
1415
google.golang.org/protobuf v0.0.0-20190514172829-e89e6244e0e8/go.mod h1:791zQGC15vDqjpmPRn1uGPu5oHy/Jzw/Q1n5JsgIIcY=
@@ -27,3 +28,5 @@ google.golang.org/protobuf v0.0.0-20190820213257-f1e905b04207 h1:ulV4hvtdAg7Xsym
2728
google.golang.org/protobuf v0.0.0-20190820213257-f1e905b04207/go.mod h1:UJqt2ZERO8/qk5A9t8Ujq6OJ+MNvOQpg9X4RKyYz9Ho=
2829
google.golang.org/protobuf v0.0.0-20190828183429-79bfdbe45be2 h1:g52BKWg08C9Z3iSV/mBCfoP+ObYXKCgdXF+p1EB9zD0=
2930
google.golang.org/protobuf v0.0.0-20190828183429-79bfdbe45be2/go.mod h1:fYMzYhnMXLj/kGDPzNOptS3IFFlQjWTlu2j3ZPET2lw=
31+
google.golang.org/protobuf v0.0.0-20191031162342-c826885a2abe h1:TqSqUz1beyIiDb4QdI6lZDstr9RxMfftdKQ0eonA0Dc=
32+
google.golang.org/protobuf v0.0.0-20191031162342-c826885a2abe/go.mod h1:qKrTvhhUFcTIUF6KuejTfRdHXKeBPoa4mtynR6usTss=

proto/extensions.go

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -486,16 +486,6 @@ func extensionAsLegacyType(v interface{}) interface{} {
486486
rv2 := reflect.New(rv.Type())
487487
rv2.Elem().Set(rv)
488488
v = rv2.Interface()
489-
case reflect.Ptr:
490-
// Represent slice types as the value itself.
491-
switch rv.Type().Elem().Kind() {
492-
case reflect.Slice:
493-
if rv.IsNil() {
494-
v = reflect.Zero(rv.Type().Elem()).Interface()
495-
} else {
496-
v = rv.Elem().Interface()
497-
}
498-
}
499489
}
500490
return v
501491
}
@@ -505,7 +495,7 @@ func extensionAsLegacyType(v interface{}) interface{} {
505495
func extensionAsStorageType(v interface{}) interface{} {
506496
switch rv := reflect.ValueOf(v); rv.Kind() {
507497
case reflect.Ptr:
508-
// Represent slice types as the value itself.
498+
// Represent non-slice types as the value itself.
509499
switch rv.Type().Elem().Kind() {
510500
case reflect.Bool, reflect.Int32, reflect.Int64, reflect.Uint32, reflect.Uint64, reflect.Float32, reflect.Float64, reflect.String:
511501
if rv.IsNil() {
@@ -514,13 +504,6 @@ func extensionAsStorageType(v interface{}) interface{} {
514504
v = rv.Elem().Interface()
515505
}
516506
}
517-
case reflect.Slice:
518-
// Represent slice types as a pointer to the value.
519-
if rv.Type().Elem().Kind() != reflect.Uint8 {
520-
rv2 := reflect.New(rv.Type())
521-
rv2.Elem().Set(rv)
522-
v = rv2.Interface()
523-
}
524507
}
525508
return v
526509
}

0 commit comments

Comments
 (0)