Documentation
¶
Index ¶
- func HumanUid(formatted ...bool) string
- func MicroUid(formatted ...bool) string
- func NanoUid(formatted ...bool) string
- func SecUid(formatted ...bool) string
- func Timestamp() string
- func TimestampMicro() string
- func TimestampNano() string
- 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
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 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 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 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 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 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
Types ¶
This section is empty.