mirror of
https://github.com/jimeh/rands.git
synced 2026-02-19 11:26:38 +00:00
feat(strings/uuidv7): add UUIDv7 generation (#10)
The UUID v7 format is a time-ordered random UUID. It uses a timestamp with millisecond precision in the most significant bits, followed by random data. This provides both uniqueness and chronological ordering, making it ideal for database primary keys and situations where sorting by creation time is desired. References: - https://uuid7.com/ - https://www.ietf.org/archive/id/draft-peabody-dispatch-new-uuid-format-04.html#name-uuid-version-7
This commit is contained in:
@@ -75,3 +75,8 @@ func ExampleUUID() {
|
||||
s := randsmust.UUID()
|
||||
fmt.Println(s) // => 5baa35a6-9a46-49b4-91d0-9530173e118d
|
||||
}
|
||||
|
||||
func ExampleUUIDv7() {
|
||||
s := randsmust.UUIDv7()
|
||||
fmt.Println(s) // => 01954a3a-a06f-7186-8774-51a770503eb2
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user