Documentation
¶
Index ¶
- Variables
- func DayUid(formatted ...bool) string
- func HexShortID() string
- func HexShortIDDay() string
- func HexShortIDHour() string
- func HexShortIDMin() string
- func HexShortIDMonth() string
- func HexShortIDSec() string
- func HexShortIDWeek() string
- func HexShortIDYear() string
- func HourUid(formatted ...bool) string
- func HumanUid(formatted ...bool) string
- func IsShortID(id string) bool
- func MicroUid(formatted ...bool) string
- func MinUid(formatted ...bool) string
- func MonthUid(formatted ...bool) string
- func NanoUid(formatted ...bool) string
- func NormalizeID(id string) string
- func SafeShortID() string
- func SafeShortIDDay() string
- func SafeShortIDHour() string
- func SafeShortIDMin() string
- func SafeShortIDMonth() string
- func SafeShortIDSec() string
- func SafeShortIDWeek() string
- func SafeShortIDYear() string
- func SecUid(formatted ...bool) string
- func Short(id string) (string, error)
- func ShortID() string
- func ShortIDCustom(alphabet string) string
- func ShortIDDay() string
- func ShortIDHour() string
- func ShortIDMin() string
- func ShortIDMonth() string
- func ShortIDSec() string
- func ShortIDWeek() string
- func ShortIDYear() string
- func ShortenBase16(id string, alphabet ...string) (string, error)
- func ShortenBase32(id string, alphabet ...string) (string, error)
- func ShortenBase36(id string, alphabet ...string) (string, error)
- func ShortenBase58(id string, alphabet ...string) (string, error)
- func ShortenBase62(id string, alphabet ...string) (string, error)
- func ShortenBase64(id string, alphabet ...string) (string, error)
- func ShortenCrockford(id string, alphabet ...string) (string, error)
- func ShortenZBase32(id string, alphabet ...string) (string, error)
- func Timestamp() string
- func TimestampMicro() string
- func TimestampNano() string
- func Unshort(s string) (string, error)
- func UnshortenBase16(s string, alphabet ...string) (string, error)
- func UnshortenBase32(s string, alphabet ...string) (string, error)
- func UnshortenBase36(s string, alphabet ...string) (string, error)
- func UnshortenBase58(s string, alphabet ...string) (string, error)
- func UnshortenBase62(s string, alphabet ...string) (string, error)
- func UnshortenBase64(s string, alphabet ...string) (string, error)
- func UnshortenCrockford(s string, alphabet ...string) (string, error)
- func UnshortenZBase32(s string, alphabet ...string) (string, error)
- func Uuid(formatted ...bool) string
- func UuidV1(formatted ...bool) string
- func UuidV3(namespace string, data []byte, formatted ...bool) (string, error)
- func UuidV4(formatted ...bool) string
- func UuidV5(namespace string, data []byte, formatted ...bool) (string, error)
- func UuidV6(formatted ...bool) string
- func UuidV7(formatted ...bool) string
- func WeekUid(formatted ...bool) string
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidByte = errors.New("character not in alphabet") ErrInvalidInput = errors.New("uid: invalid numeric input") )
Functions ¶
func DayUid ¶ added in v1.14.0
DayUid generates an 8-character time-based ID to day precision.
Format: YYYYMMDD
Example (unformatted): 20250831 (length: 8) Example (formatted): 2025-08-31 (length: 10)
Parameters: - formatted: when true, include hyphens in groups 4-2-2 (length becomes 10)
Returns: - An 8-character numeric string representing UTC date to the day
func HexShortID ¶ added in v1.12.0
func HexShortID() string
HexShortID generates a standard 14-character lowercase hexadecimal short ID. Uses the same timestamp + 4-bit rolling counter logic as SafeShortID, formatted with the standard lowercase hex alphabet "0123456789abcdef".
Returns:
- A 14-character lowercase hexadecimal string.
func HexShortIDDay ¶ added in v1.14.0
func HexShortIDDay() string
HexShortIDDay creates a 5-character Hex Base16 short ID to day precision.
func HexShortIDHour ¶ added in v1.14.0
func HexShortIDHour() string
HexShortIDHour creates a 7-character Hex Base16 short ID to hour precision.
func HexShortIDMin ¶ added in v1.14.0
func HexShortIDMin() string
HexShortIDMin creates a 9-character Hex Base16 short ID to minute precision.
func HexShortIDMonth ¶ added in v1.14.0
func HexShortIDMonth() string
HexShortIDMonth creates a 4-character Hex Base16 short ID to month precision.
func HexShortIDSec ¶ added in v1.14.0
func HexShortIDSec() string
HexShortIDSec creates a 10-character Hex Base16 short ID to second precision.
func HexShortIDWeek ¶ added in v1.14.0
func HexShortIDWeek() string
HexShortIDWeek creates a 4-character Hex Base16 short ID to ISO week precision.
func HexShortIDYear ¶ added in v1.14.0
func HexShortIDYear() string
HexShortIDYear creates a 2-character Hex Base16 short ID to year precision.
func HourUid ¶ added in v1.14.0
HourUid generates a 10-character time-based ID to hour precision.
Format: YYYYMMDDHH
Example (unformatted): 2025083115 (length: 10) Example (formatted): 20250831-15 (length: 11)
Parameters: - formatted: when true, include hyphens in groups 8-2 (length becomes 11)
Returns: - A 10-character numeric string representing UTC date/time to the hour
func HumanUid ¶
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 IsShortID ¶ added in v1.10.0
IsShortID checks whether the given string matches the format produced by ShortID: the correct length and only lowercase Crockford Base32 characters. It does NOT cover the SafeShortID/HexShortID/ShortIDCustom formats.
Parameters:
- id: the ID string to check.
Returns:
- true if id looks like a ShortID() output; false otherwise.
Example:
- ok := uid.IsShortID("sa4rc789wxg") // true
func MicroUid ¶
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 MinUid ¶ added in v1.14.0
MinUid generates a 12-character time-based ID to minute precision.
Format: YYYYMMDDHHMM
Example (unformatted): 202508311511 (length: 12) Example (formatted): 20250831-1511 (length: 13)
Parameters: - formatted: when true, include hyphens in groups 8-4 (length becomes 13)
Returns: - A 12-character numeric string representing UTC date/time to the minute
func MonthUid ¶ added in v1.14.0
MonthUid generates a 6-character time-based ID to month precision.
Format: YYYYMM
Example (unformatted): 202508 (length: 6) Example (formatted): 2025-08 (length: 7)
Parameters: - formatted: when true, include hyphens in groups 4-2 (length becomes 7)
Returns: - A 6-character numeric string representing UTC date to the month
func NanoUid ¶
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 NormalizeID ¶ added in v1.10.0
NormalizeID normalizes an ID to lowercase and trims whitespace for consistent lookups.
Parameters:
- id: the ID string to normalize.
Returns:
- The trimmed, lowercased ID.
Example:
- norm := uid.NormalizeID(" SA4RC789WXG ") // "sa4rc789wxg"
func SafeShortID ¶ added in v1.12.0
func SafeShortID() string
SafeShortID generates a fixed 14-character lowercase short ID using a vowel-free Base 16 alphabet. Core logic: microsecond timestamp shifted left by 4 bits, combined with a 4-bit rolling counter, produced by nextShortIDValue. Alphabet (Base 16, vowel-free): "0123456789bcdfgh". Every letter of standard hex is shifted to the next sequential consonant ('a'->'b', 'b'->'c', 'c'->'d', 'd'->'f', 'e'->'g', 'f'->'h') to avoid generating accidental English words; this greatly reduces but does not eliminate them (leet-speak like "b00b" is still reachable). The alphabet is in ascending byte order, so generated IDs sort chronologically.
Returns:
- A 14-character lowercase string (e.g. "05fh88gd139f8h").
func SafeShortIDDay ¶ added in v1.14.0
func SafeShortIDDay() string
SafeShortIDDay creates a 5-character Safe Base16 short ID to day precision.
func SafeShortIDHour ¶ added in v1.14.0
func SafeShortIDHour() string
SafeShortIDHour creates a 7-character Safe Base16 short ID to hour precision.
func SafeShortIDMin ¶ added in v1.14.0
func SafeShortIDMin() string
SafeShortIDMin creates a 9-character Safe Base16 short ID to minute precision.
func SafeShortIDMonth ¶ added in v1.14.0
func SafeShortIDMonth() string
SafeShortIDMonth creates a 4-character Safe Base16 short ID to month precision.
func SafeShortIDSec ¶ added in v1.14.0
func SafeShortIDSec() string
SafeShortIDSec creates a 10-character Safe Base16 short ID to second precision.
func SafeShortIDWeek ¶ added in v1.14.0
func SafeShortIDWeek() string
SafeShortIDWeek creates a 4-character Safe Base16 short ID to ISO week precision.
func SafeShortIDYear ¶ added in v1.14.0
func SafeShortIDYear() string
SafeShortIDYear creates a 2-character Safe Base16 short ID to year precision.
func SecUid ¶
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
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 ShortID ¶ added in v1.11.0
func ShortID() string
ShortID creates a new 11-character lowercase short ID. It encodes the current microsecond timestamp in Crockford Base32. Thread-safe via a lock-free CAS loop; survives backwards clock steps.
Business Logic:
- Uses time.Now().UnixMicro() as the uniqueness base.
- Maintains a package-level atomic (timestamp << 4) | counter state.
- Counter increments while the timestamp does not advance; when it would exceed 15, the timestamp is bumped by one microsecond instead of sleeping, so callers never stall and IDs never regress.
- Packs timestamp and counter into a single int64: (ts << 4) | counter.
- Encodes the composite value with a lowercase Crockford Base32 alphabet.
Notes:
- Uniqueness is per-process only: two processes generating IDs in the same microsecond can collide. The IDs are also predictable and reveal their creation time, so they are suitable for sortable database keys but NOT for security tokens or unguessable public identifiers.
Returns:
- An 11-character lowercase string (e.g. "sa4rc789wxg").
Example:
- id := uid.ShortID() // "sa4rc789wxg"
func ShortIDCustom ¶ added in v1.12.0
ShortIDCustom generates a time-ordered short ID using a user-provided custom alphabet string. Encodes the combined (timestamp << 4) | counter value using modulo arithmetic against the length of the provided alphabet.
Parameters:
- alphabet: a string of at least 2 unique single-byte (ASCII) characters. If empty, defaults to "0123456789abcdef". For IDs that sort chronologically the characters must be in ascending byte order. Panics on an invalid alphabet.
Returns:
- A time-ordered short ID encoded with the custom alphabet.
func ShortIDDay ¶ added in v1.14.0
func ShortIDDay() string
ShortIDDay creates a 4-character Crockford Base32 short ID to day precision (YYMMDD).
func ShortIDHour ¶ added in v1.14.0
func ShortIDHour() string
ShortIDHour creates a 6-character Crockford Base32 short ID to hour precision (YYMMDDHH).
func ShortIDMin ¶ added in v1.14.0
func ShortIDMin() string
ShortIDMin creates a 7-character Crockford Base32 short ID to minute precision (YYMMDDHHMM).
func ShortIDMonth ¶ added in v1.14.0
func ShortIDMonth() string
ShortIDMonth creates a 3-character Crockford Base32 short ID to month precision (YYMM).
func ShortIDSec ¶ added in v1.14.0
func ShortIDSec() string
ShortIDSec creates an 8-character Crockford Base32 short ID to second precision (YYMMDDHHMMSS).
func ShortIDWeek ¶ added in v1.14.0
func ShortIDWeek() string
ShortIDWeek creates a 3-character Crockford Base32 short ID to ISO week precision (YYWW).
func ShortIDYear ¶ added in v1.14.0
func ShortIDYear() string
ShortIDYear creates a 2-character Crockford Base32 short ID to year precision (YY).
func ShortenBase16 ¶ added in v1.9.0
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 representation of a positive integer. - alphabet: Optional custom alphabet to override default base16 alphabet.
Returns: - A base16 encoded string.
func ShortenBase32 ¶ added in v1.9.0
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 representation of a positive integer. - alphabet: Optional custom alphabet to override default base32 alphabet.
Returns: - A base32 string.
func ShortenBase36 ¶ added in v1.9.0
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 representation of a positive integer. - alphabet: Optional custom alphabet to override default base36 alphabet.
Returns: - A base36 string.
func ShortenBase58 ¶ added in v1.9.0
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 representation of a positive integer. - alphabet: Optional custom alphabet to override default base58 alphabet.
Returns: - A base58 string.
func ShortenBase62 ¶ added in v1.9.0
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 representation of a positive integer. - alphabet: Optional custom alphabet to override default base62 alphabet.
Returns: - A base62 string.
func ShortenBase64 ¶ added in v1.9.0
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 representation of a positive integer. - alphabet: Optional custom alphabet to override default base64 alphabet.
Returns: - A URL-safe base64 string.
func ShortenCrockford ¶ added in v1.9.0
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 representation of a positive integer. - alphabet: Optional custom alphabet to override default Crockford alphabet.
Returns: - A Crockford Base32 string.
func ShortenZBase32 ¶ added in v1.9.0
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 representation of a positive integer. - alphabet: Optional custom alphabet to override default z-base-32 alphabet.
Returns: - A 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
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
UnshortenBase16 converts a base16 (hexadecimal) string back to its original numeric string ID.
Example: UnshortenBase16("499602d2") -> "1234567890"
Parameters: - s: A hexadecimal string. - alphabet: Optional custom alphabet to override default base16 alphabet.
Returns: - The original numeric string ID, or an error if invalid characters are encountered.
func UnshortenBase32 ¶ added in v1.9.0
UnshortenBase32 converts a base32 string back to its original numeric string ID.
Example: UnshortenBase32("gnm6fsq") -> "1234567890"
Parameters: - s: A base32 string (case-insensitive when using default alphabet). - alphabet: Optional custom alphabet to override default base32 alphabet.
Returns: - The original numeric string ID, or an error if invalid characters are encountered.
func UnshortenBase36 ¶ added in v1.9.0
UnshortenBase36 converts a base36 string back to its original numeric string ID.
Example: UnshortenBase36("kf12oi") -> "1234567890"
Parameters: - s: A base36 string (case-insensitive when using default alphabet). - alphabet: Optional custom alphabet to override default base36 alphabet.
Returns: - The original numeric string ID, or an error if invalid characters are encountered.
func UnshortenBase58 ¶ added in v1.9.0
UnshortenBase58 converts a base58 string back to its original numeric string ID.
Example: UnshortenBase58("2V6G2p") -> "1234567890"
Parameters: - s: A base58 string. - alphabet: Optional custom alphabet to override default base58 alphabet.
Returns: - The original numeric string ID, or an error if invalid characters are encountered.
func UnshortenBase62 ¶ added in v1.9.0
UnshortenBase62 converts a base62 string back to its original numeric string ID.
Example: UnshortenBase62("1LY7vk") -> "1234567890"
Parameters: - s: A base62 string. - alphabet: Optional custom alphabet to override default base62 alphabet.
Returns: - The original numeric string ID, or an error if invalid characters are encountered.
func UnshortenBase64 ¶ added in v1.9.0
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. - alphabet: Optional custom alphabet to override default base64 alphabet.
Returns: - The original numeric string ID, or an error if invalid characters are encountered.
func UnshortenCrockford ¶ added in v1.9.0
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) when using default alphabet.
Example: UnshortenCrockford("14MM0M") -> "1234567890"
Parameters: - s: A Crockford Base32 string. - alphabet: Optional custom alphabet to override default Crockford alphabet.
Returns: - The original numeric string ID, or an error if invalid characters are encountered.
func UnshortenZBase32 ¶ added in v1.9.0
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 when using default alphabet). - alphabet: Optional custom alphabet to override default z-base-32 alphabet.
Returns: - The original numeric string ID, or an error if invalid characters are encountered.
func Uuid ¶
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 ¶
UuidV1 returns a version 1 (time-based) UUID without hyphens.
Example: 6ba7b8109dad11d180b400c04fd430c8 (length: 32)
Parameters: - formatted: when true, include hyphens
Returns: - The UUID v1 as a string
func UuidV3 ¶
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 ¶
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 ¶
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 ¶
UuidV6 returns a version 6 (time-ordered) UUID without hyphens.
Example: 1ed0c9e48f7b6b2c9c3b6a6c7a9d5e12 (length: 32)
Parameters: - formatted: when true, include hyphens
Returns: - A UUID v6 (time-ordered) without hyphens
func UuidV7 ¶
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
func WeekUid ¶ added in v1.14.0
WeekUid generates a 6-character time-based ID to ISO week precision.
Format: YYYYWW
Example (unformatted): 202535 (length: 6) Example (formatted): 2025-35 (length: 7)
Parameters: - formatted: when true, include hyphens in groups 4-2 (length becomes 7)
Returns: - A 6-character numeric string representing UTC ISO year and week
Types ¶
This section is empty.