How do I represent a UUID in a protobuf message?

后端 未结 3 746
离开以前
离开以前 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:01

    If anything, you want to use string to avoid problems with endianness. Note that a UUID and a MS GUID that have the same string representation (and therefore are the same "id") have, however, different byte-stream order (big-endian vs little-endian). If you use bytes in the protocol to communicate between Java using UUID and C# using System.Guid, you could end up with flipped IDs.

提交回复
热议问题