internal/legacy: use proto.Unmarshal from v2

Change-Id: Ic1e757a11f233657d6c3a840719ebef34d81e4f5
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/167716
Reviewed-by: Damien Neil <dneil@google.com>
This commit is contained in:
Joe Tsai 2019-03-14 14:06:05 -07:00 committed by Joe Tsai
parent f83d5bb6f0
commit 69996ba400

View File

@ -56,9 +56,8 @@ func loadFileDesc(b []byte) *descriptorpb.FileDescriptorProto {
if err != nil {
panic(err)
}
// TODO: What about extensions?
// The protoV1 API does not eagerly unmarshal extensions.
if err := proto.Unmarshal(b, m); err != nil {
err = proto.UnmarshalOptions{DiscardUnknown: true}.Unmarshal(b, m)
if err != nil {
panic(err)
}
fileDescCache.Store(&b[0], m)