Closed phbcanada closed 6 years ago
We had the exact same issue with converting grpc bytes
to uuid.UUID
so I built a convenience constructor. It was merged with this pull request.
Here's how to create a uuid.UUID
from a byte slice.
b := []byte{
0x7d, 0x44, 0x48, 0x40,
0x9d, 0xc0,
0x11, 0xd1,
0xb2, 0x45,
0x5f, 0xfd, 0xce, 0x74, 0xfa, 0xd2,
}
buuid, err := uuid.FromBytes(b)
Awesome. Thanks!
We are passing 16 byte binary UUIDs via grpc and need to be able to cast these from byte slice back to type uuid.UUID. There doesn't seem to be an easy way to do this. It would be nice if the package had a method for this. This works but is there a better way?