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
In our system, we use golang implement tcp server and python implement a test client. We construct communication protocol base on protocol buffer. I define a pb as follow:
Simple our problem:
Our server construct MsgSendError with error_code's value equal NOT_FRIEND(0x00), then serialize the pb and send binary to client. Our python client parse the binary, but can't extract error_code. If error_code's value equal MSG_INVALID(0x01), error_code could be extracted. Why? Because of python is a dynamic language?
P.S. protoc's version is 3.0.0 in our machine.
The text was updated successfully, but these errors were encountered:
This behavior is actually to be expected, because proto3 does not make a distinction between a primitive field being empty and being set to its default value (which in this case is the 0 value, NOT_FRIEND). In other words, there is no way to distinguish whether error_code was set to NOT_FRIEND or was not set at all. See here for more about proto3 enums: https://developers.google.com/protocol-buffers/docs/proto3#enum
I'll close this issue for now but feel free to reopen it if you have more questions.
When you access the field you should automatically get the default value (0 or the empty string depending on the type). Could you post some example code if this isn't working?
In our system, we use golang implement tcp server and python implement a test client. We construct communication protocol base on protocol buffer. I define a pb as follow:
Simple our problem:
Our server construct MsgSendError with error_code's value equal NOT_FRIEND(0x00), then serialize the pb and send binary to client. Our python client parse the binary, but can't extract error_code. If error_code's value equal MSG_INVALID(0x01), error_code could be extracted. Why? Because of python is a dynamic language?
P.S. protoc's version is 3.0.0 in our machine.
The text was updated successfully, but these errors were encountered: