1

I am upgrading all the libraries(go, protoc, grpc) we use. Once I updated the protoc compiler , protoc-gen-go and regenerated the protos. Some of the structs in the pb.go file have new meta fields/variables added- state, sizeCache,unknownFields. These did not exist in the old pb file.

type x struct {                                                       
    state         protoimpl.MessageState                                            
    sizeCache     protoimpl.SizeCache                                               
    unknownFields protoimpl.UnknownFields                                           
                                                                                    
    a int64  `protobuf:"varint,1,opt,name=a,proto3" json:"a,omitempty"`
    b []byte `protobuf:"bytes,2,opt,name=b,proto3" json:"b,omitempty"`
    c string `protobuf:"bytes,3,opt,name=c,proto3" json:"c,omitempty"`
}     

So addition of these fields results in compilation error, when creating this struct with the existing code. Are these fields something that needs to be taken care of by the code?

phoenix
  • 11
  • 1
  • 1
    You should show the code that is no longer compiling. It is perfectly fine for the proto library to add additional unexported fields. – Marc Jul 15 '20 at 06:29
  • If it is something hard coded by your side, it is a problem. It is perfectly okay for protocol buffers library to make changes and optimize things. – Stf Kolev Jul 15 '20 at 13:50

0 Answers0