Skip to content

Commit

Permalink
all: update to latest google.golang.org/protobuf
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
dsnet committed Jul 17, 2019
1 parent 346ae1c commit b9f5089
Show file tree
Hide file tree
Showing 30 changed files with 618 additions and 390 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/golang/protobuf

go 1.9

require google.golang.org/protobuf v0.0.0-20190620020611-d888139e7b59
require google.golang.org/protobuf v0.0.0-20190717230113-f647c82cc3c7
4 changes: 3 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ github.com/golang/protobuf v1.2.1-0.20190516215712-ae2eaafab405/go.mod h1:UmP8hh
github.com/golang/protobuf v1.2.1-0.20190523175523-a1331f0b4ab4/go.mod h1:G+fNMoyvKWZDB7PCDHF+dXbH9OeE3+JoozCd9V7i66U=
github.com/golang/protobuf v1.2.1-0.20190605195750-76c9e09470ba/go.mod h1:S1YIJXvYHGRCG2UmZsOcElkAYfvZLg2sDRr9+Xu8JXU=
github.com/golang/protobuf v1.2.1-0.20190617175902-f94016f5239f/go.mod h1:G+HpKX7pYZAVkElkAWZkr08MToW6pTp/vs+E9osFfbg=
github.com/golang/protobuf v1.2.1-0.20190620192300-1ee46dfd80dd/go.mod h1:+CMAsi9jpYf/wAltLUKlg++CWXqxCJyD8iLDbQONsJs=
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
google.golang.org/protobuf v0.0.0-20190514172829-e89e6244e0e8/go.mod h1:791zQGC15vDqjpmPRn1uGPu5oHy/Jzw/Q1n5JsgIIcY=
Expand All @@ -14,5 +15,6 @@ google.golang.org/protobuf v0.0.0-20190516215540-a95b29fbf623/go.mod h1:cWWmz5ls
google.golang.org/protobuf v0.0.0-20190522194032-21ade498bd69/go.mod h1:cJytyYi/6qdwy/+gD49hmgHcwD7zhWxE/1KPEslaZ3M=
google.golang.org/protobuf v0.0.0-20190605195314-89d49632e5cf/go.mod h1:Btug4TBaP5wNYcb2zGKDTS7WMcaPPLuqEAKfEAZWYbo=
google.golang.org/protobuf v0.0.0-20190617175724-bd7b7a9e0c26/go.mod h1:+FOB8T5/Yw4ywwdyeun9/KlDeuwFYBkNQ+kVuwj9C94=
google.golang.org/protobuf v0.0.0-20190620020611-d888139e7b59 h1:8413FO+8BbzBumkamWfo1VRHJyPBKBUeerQodlLbb0g=
google.golang.org/protobuf v0.0.0-20190620020611-d888139e7b59/go.mod h1:of3pt14Y+dOxz2tBOHXEoapPpKFC15/0zWhPAddkfsU=
google.golang.org/protobuf v0.0.0-20190717230113-f647c82cc3c7 h1:U6U+Hb+UKNGJB0eMAjUGk0wTmy73kduTIvdsEgA4Gf8=
google.golang.org/protobuf v0.0.0-20190717230113-f647c82cc3c7/go.mod h1:yGm7aNHn9Bp1NIvj6+CVUkcJshu+Usshfd3A+YxEuI8=
14 changes: 10 additions & 4 deletions internal/proto/properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"strings"
"sync"

protoV2 "google.golang.org/protobuf/proto"
"google.golang.org/protobuf/runtime/protoimpl"
)

Expand Down Expand Up @@ -251,10 +252,10 @@ func newProperties(t reflect.Type) *StructProperties {
p.OrigName = tagOneof
}

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

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

0 comments on commit b9f5089

Please sign in to comment.