util

package
v0.0.0-...-2bf20ed Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package util provides environment variable parsing helpers shared across components.

Package util provides utility functions for the PromptPipe application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateParticipantID

func GenerateParticipantID() string

GenerateParticipantID generates a unique participant ID with "p_" prefix.

func GenerateRandomAlphaNumeric

func GenerateRandomAlphaNumeric(length int) string

GenerateRandomAlphaNumeric generates a random alphanumeric string of the specified length. Uses math/rand/v2 for optimal performance and modern best practices.

func GenerateRandomHex

func GenerateRandomHex(length int) string

GenerateRandomHex generates a random hexadecimal string of the specified length. Uses math/rand/v2 with optimal entropy utilization for non-cryptographic purposes.

func GenerateRandomID

func GenerateRandomID(prefix string, hexLength int) string

GenerateRandomID generates a random ID with the specified prefix and hex length. The returned ID will be in the format: "{prefix}{hex_string}". Uses math/rand/v2 for optimal performance with modern best practices.

func GenerateResponseID

func GenerateResponseID() string

GenerateResponseID generates a unique response ID with "r_" prefix.

func GetEnvWithDefault

func GetEnvWithDefault(key, defaultValue string) string

GetEnvWithDefault returns the environment variable or a default if unset/empty.

func ParseBoolEnv

func ParseBoolEnv(key string, defaultValue bool) bool

ParseBoolEnv parses a boolean environment variable with a default value. Accepts: true/1/yes/on and false/0/no/off (case-insensitive). Invalid values return default.

func ParseFloatEnv

func ParseFloatEnv(key string, defaultValue float64) float64

ParseFloatEnv parses a float environment variable with a default fallback. For temperature-like values (0.0-1.0) caller should validate range if needed.

func ParseIntEnv

func ParseIntEnv(key string, defaultValue int) int

ParseIntEnv parses an integer environment variable with a default fallback.

Types

This section is empty.

Jump to

Keyboard shortcuts

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