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.13k stars 364 forks source link

Incorrect uuidv6 implementation #159

Open ygllq opened 3 months ago

ygllq commented 3 months ago

RFC 4122 UUIDv6 Example: 1EC9414C-232A-6B00-B3C8-9E6BDECED846 But in this library NewV6 generates ID like: 01eee693-1887-6e10-a722-9e6bdeced846 has a prefix 0

Many UUID libraries in other languages (for example python uuid6) follow the instructions of the RFC.

For UUIDv6, RFC also mentioned

The 48 bit node SHOULD be set to a pseudo-random value however implementations MAY choose to retain the old MAC address behavior from [RFC4122], Section 4.1.6 and [RFC4122], Section 4.5. For more information on MAC address usage within UUIDs see the Section 8

The last 48bit node can set to a pseudo-random value, it maybe more useful.

it512 commented 3 months ago

I will check the first problem you report and fix it as soon as possible. Regarding the second question , it is optional to use pseudo-randomness for the lower 48 bits of UUID1, 6. In addition, RFC recommends that you use uuidV7

=================

您反馈的第一个问题,我会查看,有问题会第一时间修复。 对于您反馈的第二个问题,UUID1,6 低48位使用伪随机是可选的,另外RFC推荐您用uuidV7,另外在任何情况下都应该优先考虑使用uuidV7 @ygllq