How do I represent a UUID in a protobuf message?

后端 未结 3 769
离开以前
离开以前 2021-01-03 17:25

I want to attach a UUID to a field in my protobuf User message example.

message User {
  // field containing id as UUID type
  required string email;
  optio         


        
3条回答
  •  灰色年华
    2021-01-03 18:11

    I don't have enough reputation points to make a comment, so I have to write this as an answer.

    Use a string, not a byte array unlike what some other commenters are saying. According to MS (https://docs.microsoft.com/en-us/dotnet/architecture/grpc-for-wcf-developers/protobuf-data-types), "Don't use a bytes field for Guid values. Problems with endianness (Wikipedia definition) can result in erratic behavior when Protobuf is interacting with other platforms, such as Java."

提交回复
热议问题