allocate icon indicating copy to clipboard operation
allocate copied to clipboard

Can't work with unexported fields in protobuf

Open Kybxd opened this issue 3 years ago • 1 comments

Protobuf now has 3 unexported fields

type MyPbStruct struct {
	state         protoimpl.MessageState
	sizeCache     protoimpl.SizeCache
	unknownFields protoimpl.UnknownFields

	MyInt int32 `protobuf:"varint,1,opt,name=my_int,json=friendRuid,proto3" json:"my_int,omitempty"`
}

When trying to set this struct zero

st := new(MyPbStruct)
err := allocate.Zero(st)
if err != nil{
	log.Error(err)
}

I got

struct field can't interface, &impl.MessageState{NoUnkeyedLiterals:pragma.NoUnkeyedLiterals{}, DoNotCompare:pragma.DoNotCompare{}, DoNotCopy:pragma.DoNotCopy{}, atomicMessageInfo:(*impl.MessageInfo)(nil)}

Kybxd avatar Sep 09 '22 07:09 Kybxd

Hi @Kybxd, I am facing the exact same issue did you solve it ?

medbrh avatar Nov 07 '22 17:11 medbrh