google / uuid

Go package for UUIDs based on RFC 4122 and DCE 1.1: Authentication and Security Services.
BSD 3-Clause "New" or "Revised" License
5.26k stars 362 forks source link

UUID to []byte? #50

Closed mudream4869 closed 4 years ago

mudream4869 commented 4 years ago

Is there any function to get []byte from a UUID instance, or I should write the code as below?

func getBytes(u uuid.UUID) []byte {
    b := make([]byte, 16)
    for i := range b {
        b[i] = u[i]
    }
    return b
}
inliquid commented 4 years ago

b := uuidInstance[:]

ferhatelmas commented 4 years ago

also, might see MarshalBinary