mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2025-01-01 11:58:21 +00:00
cmd/protoc-gen-go: use Merge instead of Marshal/Unmarshal
Change-Id: I689dee8417944bb0fbe19c75b7ca1accb49afb33 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/185144 Reviewed-by: Herbie Ong <herbie@google.com>
This commit is contained in:
parent
a804450cf6
commit
8b0b71e9b6
@ -183,21 +183,11 @@ func genReflectFileDescriptor(gen *protogen.Plugin, g *protogen.GeneratedFile, f
|
||||
}
|
||||
|
||||
func genFileDescriptor(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInfo) {
|
||||
// TODO: Replace this with v2 Clone.
|
||||
descProto := new(descriptorpb.FileDescriptorProto)
|
||||
b, err := proto.Marshal(f.Proto)
|
||||
if err != nil {
|
||||
gen.Error(err)
|
||||
return
|
||||
}
|
||||
if err := proto.Unmarshal(b, descProto); err != nil {
|
||||
gen.Error(err)
|
||||
return
|
||||
}
|
||||
proto.Merge(descProto, f.Proto)
|
||||
descProto.SourceCodeInfo = nil // drop source code information
|
||||
|
||||
// Trim the source_code_info from the descriptor.
|
||||
descProto.SourceCodeInfo = nil
|
||||
b, err = proto.MarshalOptions{Deterministic: true}.Marshal(descProto)
|
||||
b, err := proto.MarshalOptions{AllowPartial: true, Deterministic: true}.Marshal(descProto)
|
||||
if err != nil {
|
||||
gen.Error(err)
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user