utils

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatTimeToISO8601

func FormatTimeToISO8601(t time.Time) string

FormatTimeToISO8601 formats time to ISO 8601 string

func GenerateRandomString

func GenerateRandomString(length int) (string, error)

GenerateRandomString generates a random string of specified length

func GetConfigFilePath

func GetConfigFilePath(filename string) (string, error)

GetConfigFilePath returns the path to a specific config file

func GetConfigPath

func GetConfigPath() (string, error)

GetConfigPath returns the path to the configs directory

func GetCurrentTimestamp

func GetCurrentTimestamp() int64

GetCurrentTimestamp returns current timestamp in seconds

func GetCurrentTimestampMillis

func GetCurrentTimestampMillis() int64

GetCurrentTimestampMillis returns current timestamp in milliseconds

func GetProjectRoot

func GetProjectRoot() (string, error)

GetProjectRoot returns the absolute path to the project root directory by searching for go.mod file from the current file's directory upwards

func GetProjectRootFromWorkingDir

func GetProjectRootFromWorkingDir() (string, error)

GetProjectRootFromWorkingDir returns the project root by searching from current working directory This is useful when you want to find root from where the application is running

func IsEmpty

func IsEmpty(s string) bool

IsEmpty checks if a string is empty or contains only whitespace

func IsTimeInRange

func IsTimeInRange(t, start, end time.Time) bool

IsTimeInRange checks if given time is within the specified range

func ParseISO8601

func ParseISO8601(s string) (time.Time, error)

ParseISO8601 parses ISO 8601 string to time

func ToCamelCase

func ToCamelCase(s string) string

ToCamelCase converts snake_case to camelCase

func ToSnakeCase

func ToSnakeCase(s string) string

ToSnakeCase converts camelCase to snake_case

func Unmarshal

func Unmarshal[T any](data []byte) (T, error)

Types

This section is empty.