utils

package
v0.0.0-...-8beb243 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolToString

func BoolToString(b bool) string

BoolToString returns "true" if the given boolean is true, otherwise returns "false".

func Equal

func Equal[T any](a, b []T, cmp func(T, T) bool) bool

Equal returns true if the given slices are equal.

func GenerateRandomBytes

func GenerateRandomBytes(n int) []byte

GenerateRandomBytes generates a random byte slice of the given length.

func GetEnvOrDefault

func GetEnvOrDefault(key, defaultValue string) string

GetEnvOrDefault returns the value of the given environment variable if it exists, otherwise returns the given default value.

func GetRandomInRange

func GetRandomInRange(min, max int) int

GetRandomInRange takes a min and max value and returns a random value between the two.

func IntToString

func IntToString(i int) string

IntToString returns the string representation of the given integer.

func Max

func Max[T string | uint | uint32 | uint64 | int | int32 | int64 | float32 | float64](a, b T) T

Max returns the maximum value of the given integers.

func SliceContains

func SliceContains[T any](slice []T, v T, eq func(T, T) bool) bool

SliceContains returns true if the slice holds the value given value

func StringToBool

func StringToBool(s string) bool

StringToBool returns true if the given string is "true", otherwise returns false.

func StringToInt

func StringToInt(s string) int

StringToInt returns the integer representation of the given string.

If the string cannot be converted to an integer, this function panics.

func ToPointer

func ToPointer[T any](v T) *T

ToPointer takes any value and returns a pointer to that value.

This function is useful when you want to pass a literal value to a function that takes a pointer to a value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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