Skip to content

Commit b9f5089

Browse files
committed
all: update to latest google.golang.org/protobuf
Local changes were made to account for the following upstream changes: * Internal fields are now unexported: XXX_sizecache -> sizeCache XXX_unrecognized -> unknownFields XXX_InternalExtensions -> extensionFields * Every message has a *protoimpl.MessageState as the first field * Well-known types no longer have an XXX_WellKnownType method * MessageSets now lack the protobuf_messageset tag * Extensions of MessageSets now use their real name * Messages no longer have a XXX_OneofWrappers method Change-Id: Iec13a8b113d523ed11493fa713e7c6df8895b9ed Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/186538 Reviewed-by: Damien Neil <[email protected]>
1 parent 346ae1c commit b9f5089

30 files changed

+618
-390
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-20190620020611-d888139e7b59
5+
require google.golang.org/protobuf v0.0.0-20190717230113-f647c82cc3c7

go.sum

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ github.com/golang/protobuf v1.2.1-0.20190516215712-ae2eaafab405/go.mod h1:UmP8hh
55
github.com/golang/protobuf v1.2.1-0.20190523175523-a1331f0b4ab4/go.mod h1:G+fNMoyvKWZDB7PCDHF+dXbH9OeE3+JoozCd9V7i66U=
66
github.com/golang/protobuf v1.2.1-0.20190605195750-76c9e09470ba/go.mod h1:S1YIJXvYHGRCG2UmZsOcElkAYfvZLg2sDRr9+Xu8JXU=
77
github.com/golang/protobuf v1.2.1-0.20190617175902-f94016f5239f/go.mod h1:G+HpKX7pYZAVkElkAWZkr08MToW6pTp/vs+E9osFfbg=
8+
github.com/golang/protobuf v1.2.1-0.20190620192300-1ee46dfd80dd/go.mod h1:+CMAsi9jpYf/wAltLUKlg++CWXqxCJyD8iLDbQONsJs=
89
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
910
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
1011
google.golang.org/protobuf v0.0.0-20190514172829-e89e6244e0e8/go.mod h1:791zQGC15vDqjpmPRn1uGPu5oHy/Jzw/Q1n5JsgIIcY=
@@ -14,5 +15,6 @@ google.golang.org/protobuf v0.0.0-20190516215540-a95b29fbf623/go.mod h1:cWWmz5ls
1415
google.golang.org/protobuf v0.0.0-20190522194032-21ade498bd69/go.mod h1:cJytyYi/6qdwy/+gD49hmgHcwD7zhWxE/1KPEslaZ3M=
1516
google.golang.org/protobuf v0.0.0-20190605195314-89d49632e5cf/go.mod h1:Btug4TBaP5wNYcb2zGKDTS7WMcaPPLuqEAKfEAZWYbo=
1617
google.golang.org/protobuf v0.0.0-20190617175724-bd7b7a9e0c26/go.mod h1:+FOB8T5/Yw4ywwdyeun9/KlDeuwFYBkNQ+kVuwj9C94=
17-
google.golang.org/protobuf v0.0.0-20190620020611-d888139e7b59 h1:8413FO+8BbzBumkamWfo1VRHJyPBKBUeerQodlLbb0g=
1818
google.golang.org/protobuf v0.0.0-20190620020611-d888139e7b59/go.mod h1:of3pt14Y+dOxz2tBOHXEoapPpKFC15/0zWhPAddkfsU=
19+
google.golang.org/protobuf v0.0.0-20190717230113-f647c82cc3c7 h1:U6U+Hb+UKNGJB0eMAjUGk0wTmy73kduTIvdsEgA4Gf8=
20+
google.golang.org/protobuf v0.0.0-20190717230113-f647c82cc3c7/go.mod h1:yGm7aNHn9Bp1NIvj6+CVUkcJshu+Usshfd3A+YxEuI8=

internal/proto/properties.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"strings"
1212
"sync"
1313

14+
protoV2 "google.golang.org/protobuf/proto"
1415
"google.golang.org/protobuf/runtime/protoimpl"
1516
)
1617

@@ -251,10 +252,10 @@ func newProperties(t reflect.Type) *StructProperties {
251252
p.OrigName = tagOneof
252253
}
253254

254-
// Rename unrelated struct fields with the "XXX_" prefix since so much
255-
// user code simply checks for this to exclude special fields.
256-
if tagField == "" && tagOneof == "" && !strings.HasPrefix(p.Name, "XXX_") {
257-
p.Name = "XXX_invalid_" + p.Name
255+
// Rename unexported struct fields with the "XXX_" prefix since so much
256+
// user code simply checks for this to exclude unrelated fields.
257+
if f.PkgPath != "" {
258+
p.Name = "XXX_" + p.Name
258259
}
259260

260261
prop.Prop = append(prop.Prop, p)
@@ -268,6 +269,11 @@ func newProperties(t reflect.Type) *StructProperties {
268269
if fn, ok := reflect.PtrTo(t).MethodByName("XXX_OneofWrappers"); ok {
269270
oneofWrappers = fn.Func.Call([]reflect.Value{reflect.Zero(fn.Type.In(0))})[0].Interface().([]interface{})
270271
}
272+
if m, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(protoV2.Message); ok {
273+
if m, ok := m.ProtoReflect().(interface{ ProtoMessageInfo() *protoimpl.MessageInfo }); ok {
274+
oneofWrappers = m.ProtoMessageInfo().OneofWrappers
275+
}
276+
}
271277
if len(oneofWrappers) > 0 {
272278
prop.OneofTypes = make(map[string]*OneofProperties)
273279
for _, wrapper := range oneofWrappers {

0 commit comments

Comments
 (0)