uid

package module
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2026 License: MIT Imports: 12 Imported by: 28

README

UID (Unique ID) Open in Gitpod

Tests Status Go Report Card PkgGoDev

This package generates unique identifying strings. Largest attention is paid on human friendly unique identifiers (dated digits).

Installation

go get -u github.com/dracory/uid

Usage

package main

import (
    "fmt"
    "github.com/dracory/uid"
)

func main() {
    // HumanUid generates a UID (32 digits)
    // Format: YYYYMMDD-HHMM-SSMM-MMMMNNNRRRRRRRRR
    human := uid.HumanUid()          // unformatted, length: 32
    humanF := uid.HumanUid(true)     // formatted (8-4-4-16), length: 35

    // NanoUid generates a UID (23 digits)
    // Format: YYYYMMDD-HHMMSS-MMMMMM-NNN
    nano := uid.NanoUid()            // unformatted, length: 23
    nanoF := uid.NanoUid(true)       // formatted (8-6-6-3), length: 26

    // MicroUid generates a UID (20 digits)
    // Format: YYYYMMDD-HHMMSS-MMMMMM
    micro := uid.MicroUid()          // unformatted, length: 20
    microF := uid.MicroUid(true)     // formatted (8-6-6), length: 22

    // SecUid generates a UID (14 digits)
    // Format: YYYYMMDD-HHMMSS
    sec := uid.SecUid()              // unformatted, length: 14
    secF := uid.SecUid(true)         // formatted (8-6), length: 15

    // Unix timestamps as strings
    ts := uid.Timestamp()            // seconds, length: 10
    tsu := uid.TimestampMicro()      // microseconds, length: 16
    tsn := uid.TimestampNano()       // nanoseconds, length: 19

    // UUIDs (implemented via standard library)
    u4 := uid.Uuid()                 // v4 unformatted, length: 32
    u4f := uid.Uuid(true)            // v4 formatted, length: 36
    v1 := uid.UuidV1()               // v1 unformatted, length: 32
    v1f := uid.UuidV1(true)          // v1 formatted, length: 36
    v3, _ := uid.UuidV3("1234567890abcdef", []byte("name"))     // v3 unformatted
    v3f, _ := uid.UuidV3("1234567890abcdef", []byte("name"), true)
    v5, _ := uid.UuidV5("1234567890abcdef", []byte("name"))     // v5 unformatted
    v5f, _ := uid.UuidV5("1234567890abcdef", []byte("name"), true)
    v6 := uid.UuidV6()               // v6 unformatted, length: 32
    v6f := uid.UuidV6(true)          // v6 formatted, length: 36
    v7 := uid.UuidV7()               // v7 unformatted, length: 32
    v7f := uid.UuidV7(true)          // v7 formatted, length: 36

    fmt.Println(human, humanF, nano, nanoF, micro, microF, sec, secF,
        ts, tsu, tsn, u4, u4f, v1, v1f, v3, v3f, v5, v5f, v6, v6f, v7, v7f)

    // ID Shortening
    id := "12345678901234567890"
    short, _ := uid.ShortenBase62(id)       // "1n9XvB8P6M"
    original, _ := uid.UnshortenBase62(short) // "12345678901234567890"
}

Supported UID Types

It supports several types of unique identifiers.

The type you want to use will usually depends on two considerations:

  1. How random you want it to be? The longer the identifier, the more the chances of collision reduce
  2. How long you want the identifier to be? The longer the identifier, reduces the readability, as well as the storage space to store it.

For most of the user cases a Micro UID (20 chars) should be fine. A human UID (32 chars) should be avoided where a human is involved as too "mind bogging" to work with.

  1. Human UID (32 digits)

    Format: YYYYMMDD-HHMM-SSMM-MMMMNNNRRRRRRRRR

    2017111908492665991498485465 (with dashes: 20171119-0849-2665-991498485465)

  2. Nano UID (23 digits)

    Format: YYYYMMDD-HHMMSS-MMMMMM-NNN

    Examples:

    20171119084926659914984 (with dashes: 20171119-084926-659914-984)

  3. Micro UID (20 digits)

    Format: YYYYMMDD-HHMMSS-MMMMMM

    Examples:

    20171119084926659914 (with dashes: 20171119-084926-659914)

  4. Seconds UID (14 digits)

    Format: YYYYMMDD-HHMMSS

    Examples:

    20171119084926 (with dashes: 20171119-084926)

  5. Timestamp (10 digits) Unit timestamp, seconds precision

    Format: 1234567890

    Examples:

    1704524414

  6. TimestampMicro (16 digits) Unit timestamp, microseconds precision

    Format: 1234567890123456

    Examples:

    1704524414548721

  7. TimestampNano (19 digits) Unit timestamp, nanoseconds precision

    Format: 1234567890123456789

    Examples:

    1704524414548721308

  8. Uuid (32 characters) Random V4 UUID. UUID (Universally Unique IDentifier), also known as GUID (Globally Unique IDentifier)

    Format: abcdef1234567890abcdef1234567890

    Examples:

    459e2999bd071151a23d643da42c2cc2

UUID functions

UUIDs are implemented using only the Go standard library (no external deps).

  • Uuid(formatted ...bool) → version 4 (random) Examples: 550e8400e29b41d4a716446655440000 (32) • 550e8400-e29b-41d4-a716-446655440000 (36)

  • UuidV1(formatted ...bool) → version 1 (time-based) Examples: 6ba7b8109dad11d180b400c04fd430c8 (32) • 6ba7b810-9dad-11d1-80b4-00c04fd430c8 (36)

  • UuidV3(namespace string, data []byte, formatted ...bool) → version 3 (MD5 name-based) Examples: 3d813cbb47fb32ba91df831e1593ac29 (32) • 3d813cbb-47fb-32ba-91df-831e1593ac29 (36)

  • UuidV4(formatted ...bool) → version 4 (random) Examples: 550e8400e29b41d4a716446655440000 (32) • 550e8400-e29b-41d4-a716-446655440000 (36)

  • UuidV5(namespace string, data []byte, formatted ...bool) → version 5 (SHA-1 name-based) Examples: 21f7f8de80515b8986800195ef798b6a (32) • 21f7f8de-8051-5b89-8680-0195ef798b6a (36)

  • UuidV6(formatted ...bool) → version 6 (time-ordered) Examples: 1ed0c9e48f7b6b2c9c3b6a6c7a9d5e12 (32) • 1ed0c9e4-8f7b-6b2c-9c3b-6a6c7a9d5e12 (36)

  • UuidV7(formatted ...bool) → version 7 (Unix time-based) Examples: 01890f5f3d9c7a0e8a7b6c5d4e3f2a10 (32) • 01890f5f-3d9c-7a0e-8a7b-6c5d4e3f2a10 (36)

ID Shortening

The package provides functions to shorten numeric string IDs into more compact representations using various base encodings. This is useful for creating URL-friendly or human-readable IDs from large numbers.

Method Encoding Alphabet Case-Sensitive Human-Facing
ShortenBase16 Hexadecimal 0-9, a-f No No
ShortenBase32 Base32 (RFC 4648) a-z, 2-7 No Yes
ShortenCrockford Crockford Base32 0-9, A-Z (exc. I,L,O,U) No (Normalizes) Best
ShortenBase36 Base36 0-9, a-z No Yes
ShortenBase58 Base58 (Bitcoin) 1-9, A-Z, a-z (exc. 0,O,I,l) Yes Better
ShortenBase62 Base62 0-9, A-Z, a-z Yes No
ShortenBase64 Base64 (URL-safe) A-Z, a-z, 0-9, -, _ Yes No
ShortenZBase32 z-base-32 y,b,n,d,r,f,g,8,e,j... No Good

Example:

id := "12345678901234567890"
short, _ := uid.ShortenBase62(id)       // "1n9XvB8P6M"
original, _ := uid.UnshortenBase62(short) // "12345678901234567890"
Comparison Table

Using a sample HumanUid as input:

Operation Result Length
Original HumanUid 20260116055547619570214289007495 32
ShortenBase16 ffb7f7358fa8ad8f0adb27e387 26
ShortenBase32 p7n7xgwh2rlmpblnspy4h 21
ShortenCrockford FZDZQ6P7THBCF1BDJFRW7 21
ShortenZBase32 x9p9zgs84tmcxbmp1xah8 21
ShortenBase36 1ik90wbiqnpjge668igef 21
ShortenBase58 NJMxnyUkCcK1mbKaR4 18
ShortenBase62 6qz9D7Ih28OnrKPXj5 18
ShortenBase64 D_t_c1j6itjwrbJ-OH 18

Using a sample SecUid as input:

Operation Result Length
Original SecUid 20260116060140 14
ShortenBase16 126d2d0557ec 12
ShortenBase32 snuwqkv7m 9
ShortenCrockford JDMPGANZC 9
ShortenZBase32 1pwsoki9c 9
ShortenBase36 76jda01yk 9
ShortenBase58 ABCY5ZqV 8
ShortenBase62 5kgp4HO8 8
ShortenBase64 Em0tBVfs 8

Using a sample MicroUid as input:

Operation Result Length
Original MicroUid 20260116060209548481 20
ShortenBase16 1192a6436ccfa0cc1 17
ShortenBase32 rskteg3gpudgb 13
ShortenCrockford HJAK46V6FM361 13
ShortenZBase32 t1kurg5gxwdgb 13
ShortenBase36 49xd7r0cxnoht 13
ShortenBase58 p2fBzoDdpyN 11
ShortenBase62 O8dXskGYQfx 11
ShortenBase64 RkqZDbM-gzB 11

Using a sample NanoUid as input:

Operation Result Length
Original NanoUid 20260116060418792413315 23
ShortenBase16 44a4d97764168aad883 19
ShortenBase32 rfe3f3wifukvwed 15
ShortenCrockford H54V5VP85MANP43 15
ShortenZBase32 tfr5f5sefwkisrd 15
ShortenBase36 3arqv3acnfg822r 15
ShortenBase58 EyqbSbbMe7wtW 13
ShortenBase62 6HLJqV3vQ4U1j 13
ShortenBase64 ESk2XdkFoqtiD 13

Using a sample Timestamp (seconds) as input:

Operation Result Length
Original Timestamp 1768543518 10
ShortenBase16 6969d51e 8
ShortenBase32 buwtvi6 7
ShortenCrockford 1MPKN8Y 7
ShortenZBase32 bwsuie6 7
ShortenBase36 t8y0wu 6
ShortenBase58 3hHFNd 6
ShortenBase62 1vgcxS 6
ShortenBase64 BpadUe 6

Using a sample TimestampMicro (microseconds) as input:

Operation Result Length
Original TimestampMicro 1768543534819239 16
ShortenBase16 6487b2129a7a7 13
ShortenBase32 bsipmqstj5h 11
ShortenCrockford 1J8FCGJK9X7 11
ShortenZBase32 b1exco1uj78 11
ShortenBase36 hew9om6uuf 10
ShortenBase58 Eoye75bHY 9
ShortenBase62 86CCRTsQx 9
ShortenBase64 GSHshKaen 9

Using a sample TimestampNano (nanoseconds) as input:

Operation Result Length
Original TimestampNano 1768543548681502200 19
ShortenBase16 188b20fcc4f83df8 16
ShortenBase32 brcza7tcpqppy 13
ShortenCrockford 1H2S0ZK2FGFFR 13
ShortenZBase32 btn3y9unxoxxa 13
ShortenBase36 dfpsd65np7nc 12
ShortenBase58 576wZ6w7qyR 11
ShortenBase62 26dwmwO2cbw 11
ShortenBase64 BiLIPzE-D34 11

Change Log

2026.01.16 - Add ID shortening and unshortening (Base16,32,36,58,62,64,Crockford,ZBase32)

2025.09.01 - Add optional hyphen formatting

2025.08.31 - Move UUID functions/tests into separate files

2024.01.06 - Added Timestamp and Uuid functions

2021.12.19 - Master branch changed to main

2021.12.19 - Added tests

Similar Packages

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidByte  = errors.New("character not in alphabet")
	ErrInvalidInput = errors.New("uid: invalid numeric input")
)

Functions

func HumanUid

func HumanUid(formatted ...bool) string

HumanUid generates a 32-character time-prefixed unique ID.

Format (conceptual): YYYYMMDDHHMMSSMMMMMMM + random suffix, truncated to 32.

Example (unformatted): 20250831151133000012345678901234 (length: 32) Example (formatted): 20171119-0849-2665-991498485465 (length: 35)

Parameters: - formatted: when true, include hyphens in groups 8-4-4-16 (length becomes 35)

Returns: - A 32-character uppercase numeric string suitable for human-readable IDs

func MicroUid

func MicroUid(formatted ...bool) string

MicroUid generates a 20-character time-prefixed unique ID.

Format (conceptual): YYYYMMDDHHMMSSMMMMMMM + random suffix, truncated to 20.

Example (unformatted): 20250831151133000012 (length: 20) Example (formatted): 20171119-084926-659914 (length: 22)

Parameters: - formatted: when true, include hyphens in groups 8-6-6 (length becomes 22)

Returns: - A 20-character numeric string

func NanoUid

func NanoUid(formatted ...bool) string

NanoUid generates a 23-character time-prefixed unique ID.

Format (conceptual): YYYYMMDDHHMMSSMMMMMMM + random suffix, truncated to 23.

Example (unformatted): 20250831151133000012345 (length: 23) Example (formatted): 20171119-084926-659914-984 (length: 26)

Parameters: - formatted: when true, include hyphens in groups 8-6-6-3 (length becomes 26)

Returns: - A 23-character numeric string

func SecUid

func SecUid(formatted ...bool) string

SecUid generates a 14-character time-based ID.

Format: YYYYMMDDHHMMSS

Example (unformatted): 20250831151133 (length: 14) Example (formatted): 20171119-084926 (length: 15)

Parameters: - formatted: when true, include hyphens in groups 8-6 (length becomes 15)

Returns: - A 14-character numeric string representing UTC date/time to the second

func Short added in v1.9.0

func Short(id string) (string, error)

Short converts a numeric ID string to a short, human-friendly representation using Base58.

Parameters: - id: A numeric string ID (may contain hyphens which are ignored).

Returns: - A shortened string representation, or an error if input is invalid.

func ShortenBase16 added in v1.9.0

func ShortenBase16(id string) (string, error)

ShortenBase16 converts a numeric string ID to a base16 (hexadecimal) string.

Benefits: - Standard hexadecimal representation. - Compatible with most systems and easily parsed.

Drawbacks: - Least compact representation; results in the longest strings.

Example: ShortenBase16("1234567890") -> "499602d2"

Parameters: - id: A numeric string represention of a positive integer.

Returns: - A lowercase hexadecimal string.

func ShortenBase32 added in v1.9.0

func ShortenBase32(id string) (string, error)

ShortenBase32 converts a numeric string ID to a base32 string (RFC 4648).

Benefits: - Case-insensitive and safe for filesystems. - Compact representation using only 32 characters.

Drawbacks: - Less compact than Base58/Base62. - Includes 'l' and 'i' which can be visually similar in some fonts.

Example: ShortenBase32("1234567890") -> "gnm6fsq"

Parameters: - id: A numeric string represention of a positive integer.

Returns: - A lowercase base32 string.

func ShortenBase36 added in v1.9.0

func ShortenBase36(id string) (string, error)

ShortenBase36 converts a numeric string ID to a base36 string.

Benefits: - Uses all digits and lowercase letters (0-9, a-z). - Case-insensitive and widely used for compact IDs.

Drawbacks: - Includes 'l', '1', 'o', and '0', which can be visually confusing.

Example: ShortenBase36("1234567890") -> "kf12oi"

Parameters: - id: A numeric string represention of a positive integer.

Returns: - A lowercase base36 string.

func ShortenBase58 added in v1.9.0

func ShortenBase58(id string) (string, error)

ShortenBase58 converts a numeric string ID to a base58 string.

Benefits: - Human-friendly: avoids ambiguous characters like 0, O, I, and l. - No non-alphanumeric characters, making it safe for double-clicking to select.

Drawbacks: - Case-sensitive; requires exact casing for decoding.

Example: ShortenBase58("1234567890") -> "2V6G2p"

Parameters: - id: A numeric string represention of a positive integer.

Returns: - A base58 string (mixed case).

func ShortenBase62 added in v1.9.0

func ShortenBase62(id string) (string, error)

ShortenBase62 converts a numeric string ID to a base62 string.

Benefits: - Maximum density using all standard alphanumeric characters (0-9, A-Z, a-z). - Very compact and widely supported by URL shorteners.

Drawbacks: - Case-sensitive, prone to manual entry errors. - Includes visually similar characters (e.g., 'I', 'l', '1', 'O', '0').

Example: ShortenBase62("1234567890") -> "1LY7vk"

Parameters: - id: A numeric string represention of a positive integer.

Returns: - A base62 string (mixed case).

func ShortenBase64 added in v1.9.0

func ShortenBase64(id string) (string, error)

ShortenBase64 converts a numeric string ID to a URL-safe base64 string.

Benefits: - Extremely compact representation. - Safe for use in URLs (uses '-' and '_' instead of '+' and '/').

Drawbacks: - Case-sensitive, which can lead to errors if manually typed. - Contains visually similar characters (e.g., 'O' and '0', 'I' and 'l'). - Includes '-' and '_', which can interfere with double-click selection in some UIs. - Not recommended for human-facing IDs; consider Base58 or Crockford instead.

Example: ShortenBase64("1234567890") -> "BJlg8u"

Parameters: - id: A numeric string represention of a positive integer.

Returns: - A URL-safe base64 string.

func ShortenCrockford added in v1.9.0

func ShortenCrockford(id string) (string, error)

ShortenCrockford converts a numeric string ID to a Crockford Base32 string.

Benefits: - Highly human-readable and designed to avoid common transcription errors. - Excludes ambiguous characters like I, L, O, and U.

Drawbacks: - Less compact than Base62/Base64.

Example: ShortenCrockford("1234567890") -> "14MM0M"

Parameters: - id: A numeric string represention of a positive integer.

Returns: - An uppercase Crockford Base32 string.

func ShortenZBase32 added in v1.9.0

func ShortenZBase32(id string) (string, error)

ShortenZBase32 converts a numeric string ID to a z-base-32 string.

Benefits: - Optimized for human readability and memorability. - Alphabet is designed to put easiest-to-recognize characters in most-used positions.

Drawbacks: - Non-standard alphabet; not as widely supported as RFC 4648 Base32.

Example: ShortenZBase32("1234567890") -> "4pk9xyo"

Parameters: - id: A numeric string represention of a positive integer.

Returns: - A lowercase z-base-32 string.

func Timestamp

func Timestamp() string

Timestamp returns the current Unix timestamp in seconds as a string.

Example: 1725111153 (length: 10)

Parameters: - None

Returns: - Unix timestamp in seconds (base-10 string)

func TimestampMicro

func TimestampMicro() string

TimestampMicro returns the current Unix timestamp in microseconds as a string.

Example: 1725111153123456 (length: 16)

Parameters: - None

Returns: - Unix timestamp in microseconds (base-10 string)

func TimestampNano

func TimestampNano() string

TimestampNano returns the current Unix timestamp in nanoseconds as a string.

Example: 1725111153123456789 (length: 19)

Parameters: - None

Returns: - Unix timestamp in nanoseconds (base-10 string)

func Unshort added in v1.9.0

func Unshort(s string) (string, error)

Unshort converts a shortened string (Base58) back to its original numeric ID.

Parameters: - s: A shortened string ID (Base58).

Returns: - The original numeric string ID, or an error if decoding fails.

func UnshortenBase16 added in v1.9.0

func UnshortenBase16(s string) (string, error)

UnshortenBase16 converts a base16 (hexadecimal) string back to its original numeric string ID.

Example: UnshortenBase16("499602d2") -> "1234567890"

Parameters: - s: A hexadecimal string.

Returns: - The original numeric string ID, or an error if invalid characters are encountered.

func UnshortenBase32 added in v1.9.0

func UnshortenBase32(s string) (string, error)

UnshortenBase32 converts a base32 string back to its original numeric string ID.

Example: UnshortenBase32("gnm6fsq") -> "1234567890"

Parameters: - s: A base32 string (case-insensitive).

Returns: - The original numeric string ID, or an error if invalid characters are encountered.

func UnshortenBase36 added in v1.9.0

func UnshortenBase36(s string) (string, error)

UnshortenBase36 converts a base36 string back to its original numeric string ID.

Example: UnshortenBase36("kf12oi") -> "1234567890"

Parameters: - s: A base36 string (case-insensitive).

Returns: - The original numeric string ID, or an error if invalid characters are encountered.

func UnshortenBase58 added in v1.9.0

func UnshortenBase58(s string) (string, error)

UnshortenBase58 converts a base58 string back to its original numeric string ID.

Example: UnshortenBase58("2V6G2p") -> "1234567890"

Parameters: - s: A base58 string.

Returns: - The original numeric string ID, or an error if invalid characters are encountered.

func UnshortenBase62 added in v1.9.0

func UnshortenBase62(s string) (string, error)

UnshortenBase62 converts a base62 string back to its original numeric string ID.

Example: UnshortenBase62("1LY7vk") -> "1234567890"

Parameters: - s: A base62 string.

Returns: - The original numeric string ID, or an error if invalid characters are encountered.

func UnshortenBase64 added in v1.9.0

func UnshortenBase64(s string) (string, error)

UnshortenBase64 converts a URL-safe base64 string back to its original numeric string ID.

Example: UnshortenBase64("BJlg8u") -> "1234567890"

Parameters: - s: A URL-safe base64 string.

Returns: - The original numeric string ID, or an error if invalid characters are encountered.

func UnshortenCrockford added in v1.9.0

func UnshortenCrockford(s string) (string, error)

UnshortenCrockford converts a Crockford Base32 string back to its original numeric string ID.

Features: - Supports normalization: converts to uppercase, removes hyphens. - Maps visually similar characters (O -> 0, I/L -> 1) to reduce errors.

Example: UnshortenCrockford("14MM0M") -> "1234567890"

Parameters: - s: A Crockford Base32 string.

Returns: - The original numeric string ID, or an error if invalid characters are encountered.

func UnshortenZBase32 added in v1.9.0

func UnshortenZBase32(s string) (string, error)

UnshortenZBase32 converts a z-base-32 string back to its original numeric string ID.

Example: UnshortenZBase32("4pk9xyo") -> "1234567890"

Parameters: - s: A z-base-32 string (case-insensitive).

Returns: - The original numeric string ID, or an error if invalid characters are encountered.

func Uuid

func Uuid(formatted ...bool) string

Uuid returns a random UUID (version 4) without hyphens.

Example: 550e8400e29b41d4a716446655440000 (length: 32)

https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_(random)

Parameters: - formatted: when true, include hyphens

Returns: - A random UUID (version 4) without hyphens

func UuidV1

func UuidV1(formatted ...bool) string

UuidV1 returns a version 1 (time-based) UUID without hyphens.

Example: 6ba7b8109dad11d180b400c04fd430c8 (length: 32)

https://en.wikipedia.org/wiki/Universally_unique_identifier#Versions_1_and_6_(date-time_and_MAC_address)

Parameters: - formatted: when true, include hyphens

Returns: - The UUID v1 as a string

func UuidV3

func UuidV3(namespace string, data []byte, formatted ...bool) (string, error)

UuidV3 returns a version 3 (MD5 name-based) UUID. Provide a 16-byte namespace UUID and arbitrary data.

Example (no hyphens): 3d813cbb47fb32ba91df831e1593ac29 (length: 32)

https://en.wikipedia.org/wiki/Universally_unique_identifier#Versions_3_and_5_(namespace_name-based)

Parameters: - namespace: a 16-byte UUID (as bytes) used as the namespace - data: the name bytes to hash - formatted: when true, include hyphens

Returns: - The UUID v3 as a string, or an error

func UuidV4

func UuidV4(formatted ...bool) string

UuidV4 returns a random UUID (version 4) without hyphens.

Example: 550e8400e29b41d4a716446655440000 (length: 32)

https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_(random)

Parameters: - formatted: when true, include hyphens

Returns: - A random UUID (version 4) without hyphens

func UuidV5

func UuidV5(namespace string, data []byte, formatted ...bool) (string, error)

UuidV5 returns a version 5 (SHA-1 name-based) UUID. Provide a 16-byte namespace UUID and arbitrary data.

Example (no hyphens): 21f7f8de80515b8986800195ef798b6a (length: 32)

https://en.wikipedia.org/wiki/Universally_unique_identifier#Versions_3_and_5_(namespace_name-based)

Parameters: - namespace: a 16-byte UUID (as bytes) used as the namespace - data: the name bytes to hash - formatted: when true, include hyphens

Returns: - The UUID v5 as a string, or an error

func UuidV6

func UuidV6(formatted ...bool) string

UuidV6 returns a version 6 (time-ordered) UUID without hyphens.

Example: 1ed0c9e48f7b6b2c9c3b6a6c7a9d5e12 (length: 32)

Draft: https://en.wikipedia.org/wiki/Universally_unique_identifier#Versions_1_and_6_(date-time_and_MAC_address)

Parameters: - formatted: when true, include hyphens

Returns: - A UUID v6 (time-ordered) without hyphens

func UuidV7

func UuidV7(formatted ...bool) string

UuidV7 returns a version 7 (Unix time-based) UUID without hyphens.

Example: 01890f5f3d9c7a0e8a7b6c5d4e3f2a10 (length: 32)

Draft: https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_7_(timestamp_and_random)

Parameters: - formatted: when true, include hyphens

Returns: - A UUID v7 (Unix time-based) without hyphens

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL