You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I debug the process of encoding Person struct, here, when Education struct is marshaled, u.cachedsize() tries to check if the sizecache field is valid, when value of u.sizecache is zeroField it assumes valid, then it returns the wrong int which starts at offset 0. In this case, u.sizecache should be 40, and p.Ed.XXX_sizecache is 11 which encoded as 0b.
The text was updated successfully, but these errors were encountered:
The XXX methods and fields are not to be interacted with directly. As you have correctly noted, XXX_Marshal makes assumptions about the validity of XXX_sizecache. This is working as intended. Instead, the proto.Marshal function should be used.
I should note that the compatibility section reserves the right to add/remove XXX methods. In fact, they will be going away in the future. See #276.
What version of protobuf and what language are you using?
protobuf version:
language: Go
What did you do?
Step 1
define
test.proto
fileStep 2
generate
Go
codeStep 3
check encoded message
What did you expect to see?
it should output,
What did you see instead?
but it outputs,
the
dd 97 d1 08
part should be0b
.I debug the process of encoding
Person
struct, here, whenEducation
struct is marshaled,u.cachedsize()
tries to check if thesizecache
field is valid, when value ofu.sizecache
iszeroField
it assumes valid, then it returns the wrong int which starts at offset 0. In this case,u.sizecache
should be 40, andp.Ed.XXX_sizecache
is 11 which encoded as0b
.The text was updated successfully, but these errors were encountered: