Documentation
¶
Overview ¶
Package idHelpers provides helpers for generating and formatting IDs.
Index ¶
- Variables
- func BuildCompositeID(part ...any) (compositeID string, encodedCompositeID string, err error)
- func Decode(in string) string
- func Encode(in string) string
- func GetUUID() string
- func GetUUIDv2() string
- func GetUUIDv2Payload(uuid string) string
- func GetUUIDv2WithPayload(payload string) (string, error)
- func InspectUUIDv2(uuid string) string
- func ParseCompositeID(compositeID string) string
- func SanitizeID(id string) string
Constants ¶
This section is empty.
Variables ¶
var DELIMITER string
var SEP string = "⋮"
Functions ¶
func BuildCompositeID ¶ added in v1.3.4
BuildCompositeID builds a composite identifier by sanitizing each part and joining them with the configured delimiter. It also returns the encoded (hashed) form of the composite ID.
func Decode ¶
Decode reverses a path-safe transformation applied by `htmlHelpers.ToPathSafe`. If decoding fails, it logs the error and returns an empty string.
func Encode ¶
Encode returns a SHA3-256 hex digest of a path-safe version of the input. It trims spaces, removes internal spaces, converts to a path-safe string, and then hashes the result. On error, it logs and returns an empty string.
func GetUUID ¶
func GetUUID() string
GetUUID returns a legacy time-based identifier string comprising the current date/time, process UID (if available), and a random component. It is intended for human-readable tracing rather than cryptographic uniqueness.
func GetUUIDv2 ¶
func GetUUIDv2() string
GetUUIDv2 generates a KSUID (K-Sortable Unique ID) and returns it as a string. KSUIDs are globally unique and time-sortable identifiers.
func GetUUIDv2Payload ¶
GetUUIDv2Payload extracts and returns the payload from a KSUID string. If parsing fails, it logs the error and returns an empty string.
func GetUUIDv2WithPayload ¶
GetUUIDv2WithPayload generates a KSUID containing a fixed-size payload. The payload is right-padded to 16 bytes if shorter and must not exceed 16 bytes. Returns the KSUID string or an error if generation fails.
func InspectUUIDv2 ¶
InspectUUIDv2 returns a human-readable summary of a KSUID including its time and payload contents. Returns an empty string if parsing fails.
func ParseCompositeID ¶ added in v1.3.4
ParseCompositeID is a placeholder that will parse a composite ID back into its constituent parts. Currently returns an empty string.
func SanitizeID ¶ added in v1.3.4
SanitizeID normalizes an identifier by camel-casing, removing special characters, trimming whitespace, and stripping underscores/hyphens. If the input appears to be a hash (example length), it is lowercased.
Types ¶
This section is empty.