Documentation
¶
Index ¶
- func B64DecodeMsg(b64Key string, offsetF ...int) ([]byte, error)
- func ChunkBy[T any](items []T, chunkSize int) (chunks [][]T)
- func Contains(s []string, str string) bool
- func CreateKey(key []byte) []byte
- func Die(msg string)
- func DifferenceInSlices(l1, l2 []string) ([]string, []string, []string)
- func GetEnvDefault(key string, defaultVal string) string
- func GetEnvOrDie(key string) string
- func InBetween(i, min, max int) bool
- func MaybeDie(err error, msg string)
- func Print(level, msg string)
- func TimePtr(t time.Time) time.Time
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func B64DecodeMsg ¶
B64DecodeMsg decodes a base64 encoded key and returns a subset of the key starting from the specified offset.
Parameters:
- b64Key: The base64 encoded key to be decoded.
- offsetF: An optional integer representing the offset from which to start the subset of the key. If not provided, it defaults to 7.
Returns:
- []byte: The subset of the key starting from the specified offset.
- error: An error if the decoding or subset operation fails.
func ChunkBy ¶
ChunkBy splits a slice of items into smaller chunks of a specified size.
items: The slice of items to be split. chunkSize: The size of each chunk. [][]T: A slice of slices, where each slice represents a chunk of items.
func Contains ¶
Contains checks if a string is present in a slice of strings.
Parameters: - s: the slice of strings to search in. - str: the string to search for.
Returns: - bool: true if the string is found, false otherwise.
func CreateKey ¶
CreateKey generates a key for encryption.
key: The byte array used to generate the key. Returns: The generated key.
func Die ¶
func Die(msg string)
Die exits the program after logging an error message.
It takes a message as a parameter and does not return anything.
func DifferenceInSlices ¶
DifferenceInSlices Returns missing from List1 but in list 2 missing from List2 but in list 1 common in both
func GetEnvDefault ¶
GetEnvDefault retrieves the value of the environment variable specified by the key. If the environment variable does not exist, it returns the default value.
Parameters: - key: the name of the environment variable to retrieve. - defaultVal: the value to return if the environment variable does not exist.
Return: - string: the value of the environment variable or the default value.
func GetEnvOrDie ¶
GetEnvOrDie returns the value of the specified environment variable or exits the program.
It takes a key string as a parameter and returns a string value.
func InBetween ¶
InBetween checks if a number is within a given range.
Parameters:
- i: the number to check
- min: the minimum range value (inclusive)
- max: the maximum range value (inclusive)
Returns:
- bool: true if the number is within the range, false otherwise.
func MaybeDie ¶
MaybeDie is a function that checks if an error exists and calls the Die function with a formatted error message if it does.
Parameters: - err: the error to check. - msg: the message to include in the error message.
Types ¶
This section is empty.