Update Uid() func to v4 Unique id.

Reduce Collisions and Standard RFC 4122
This commit is contained in:
Trinh Dinh Bien 2017-07-27 15:04:59 +07:00 committed by GitHub
parent a51f5994bb
commit d2eb7e664a
1 changed files with 6 additions and 0 deletions

View File

@ -19,5 +19,11 @@ func Uid() string {
// for random bits.
panic(err)
}
// UUID version 4
id[6] = (id[6] & 0x0f) | (4<<4)
// SetVariant sets variant bits as described in RFC 4122.
id[8] = (id[8] & 0xbf | 0x80)
return hex.EncodeToString(id)
}