idHelpers

package
v1.3.7 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: Apache-2.0 Imports: 13 Imported by: 14

Documentation

Overview

Package idHelpers provides helpers for generating and formatting IDs.

Index

Constants

This section is empty.

Variables

View Source
var DELIMITER string
View Source
var SEP string = "⋮"

Functions

func BuildCompositeID added in v1.3.4

func BuildCompositeID(part ...interface{}) (compositeID string, encodedCompositeID string, err error)

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

func Decode(in string) string

Decode reverses a path-safe transformation applied by `htmlHelpers.ToPathSafe`. If decoding fails, it logs the error and returns an empty string.

func Encode

func Encode(in string) string

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

func GetUUIDv2Payload(uuid string) string

GetUUIDv2Payload extracts and returns the payload from a KSUID string. If parsing fails, it logs the error and returns an empty string.

func GetUUIDv2WithPayload

func GetUUIDv2WithPayload(payload string) (string, error)

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

func InspectUUIDv2(uuid string) string

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

func ParseCompositeID(compositeID string) string

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

func SanitizeID(id string) string

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.

func UUID2String

func UUID2String(uuid string) string

UUID2String formats a legacy `GetUUID` value into a readable string showing segmented components and a human-friendly date/time breakdown.

Types

This section is empty.

Jump to

Keyboard shortcuts

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