Documentation
¶
Index ¶
- Constants
- func BoolToString(value bool) string
- func CopyCmd() string
- func DateToString(value *time.Time) string
- func DirExists(pathParts ...string) bool
- func EnsureDir(pathElem ...string) string
- func EnsureModTime(filePath string) time.Time
- func EnsureNoDir(pathElem ...string) string
- func FileExists(pathParts ...string) bool
- func Float32ToString(value float32) string
- func Float64ToString(value float64) string
- func GetFirstMapValue[K cmp.Ordered, V any](m map[K]V) (value V)
- func GetOneMapValue[K cmp.Ordered, V any](m map[K]V) (value V)
- func GetSortedKeys[K cmp.Ordered, V any](m map[K]V) (keys []K)
- func GetSortedValues[K cmp.Ordered, V any](m map[K]V) (values []V)
- func IfThenElse[T any](condition bool, valueIfTrue, valueIfFalse T) T
- func InSlice[V comparable](s []V, el V) bool
- func Int64ToString(value int64) string
- func IntToString(value int) string
- func IsLinux() bool
- func IsWindows() bool
- func KebabToPascal(s string) string
- func MapFn[T, U any](input []T, transform func(T) U) []U
- func MoveCmd() string
- func Now() *time.Time
- func PanicIfErr(err error)
- func PanicMsg(str string, params ...any)
- func PanicMsgIf(cond bool, str string, params ...any)
- func PanicMsgIfErr(err error, str string, params ...any)
- func PascalToCamel(s string) string
- func PascalToKebab(s string) string
- func PascalToSnake(s string) string
- func RandomString(length int) string
- func ReadFile(filename string, failIfNotExist bool) []byte
- func ReadFileFromJSON[T any, Y *T](filename string, obj Y, failIfNotExist bool) Y
- func ReadFileFromYAML[T any, Y *T](filename string, obj Y, failIfNotExist bool) Y
- func RemoveCmd() string
- func ReplaceInFile(filename string, replacements map[string]string)
- func StringToBool(valueAsString, context string) bool
- func StringToDate(valueAsString, context string) *time.Time
- func StringToFloat32(valueAsString, context string) float32
- func StringToFloat64(valueAsString, context string) float64
- func StringToInt(valueAsString, context string) int
- func StringToInt64(valueAsString, context string) int64
- func ToPascal(s string) string
- func WriteBytesToFile(filename string, bytes []byte)
- func WriteJsonObjToFile(filename string, obj any)
- func WriteStringToFile(filename string, content string, params ...any)
- func WriteToFile(content string, filepaths ...string)
Constants ¶
const RFC3339Milli = "2006-01-02T15:04:05.000Z07:00"
custom time format, on top of the most used RFC3339
Variables ¶
This section is empty.
Functions ¶
func BoolToString ¶
BoolToString converts a boolean to a string
func DateToString ¶
DateToString converts a date to a string
func EnsureModTime ¶
Returns the given file's modification time, or panics
func EnsureNoDir ¶
EnsureNoDir removes the directory with the given path elements
func FileExists ¶
FileExists checks if a file exists at the specified path.
func Float32ToString ¶
Float32ToString converts a float32 to a string
func Float64ToString ¶
Float64ToString converts a float64 to a string
func GetFirstMapValue ¶
GetFirstMapValue returns the value corresponding to the first key, having sorted the keys beforehand
func GetOneMapValue ¶
GetOneMapValue randomly returns a value from the map
func GetSortedKeys ¶
GetSortedKeys returns a sorted slice of keys from a map. K must be a comparable type, which is a constraint satisfied by all types that can be map keys.
func GetSortedValues ¶
GetSortedKeys returns a sorted slice of values from a map. K must be a comparable type, which is a constraint satisfied by all types that can be map keys.
func IfThenElse ¶
IfThenElse returns the valueIfTrue if the condition is true, otherwise it returns the valueIfFalse
func InSlice ¶
func InSlice[V comparable](s []V, el V) bool
InSlice returns true if the slice s contains the given element el
func Int64ToString ¶
Int64ToString converts a int64 to a string
func KebabToPascal ¶
KebabToPascal converts a kebab-case string to PascalCase
func MapFn ¶
func MapFn[T, U any](input []T, transform func(T) U) []U
Generic Map function for slices
func PanicMsgIf ¶
PanicMsgIf panics with the given message if the condition is true
func PanicMsgIfErr ¶
PanicMsgIfErr panics with the given message if the error is not nil
func PascalToCamel ¶
PascalToCamel converts a PascalCase string to camelCase.
func PascalToKebab ¶
PascalToKebab converts a PascalCase string to kebab-case.
func PascalToSnake ¶
PascalToSnake converts a PascalCase string to snake_case.
func RandomString ¶
RandomString generates a random string of the given length
func ReadFileFromJSON ¶
ReadFileFromJSON reads the file with the given path and unmarshals the JSON object
func ReadFileFromYAML ¶
ReadFileFromYAML reads the file with the given path and unmarshals the YAML object
func ReplaceInFile ¶
ReplaceInFile replaces the given replacements in the file with the given path
func StringToBool ¶
StringToBool converts a string to a boolean
func StringToDate ¶
StringToDate converts a string to a date
func StringToFloat32 ¶
StringToFloat32 converts a string to a float32
func StringToFloat64 ¶
StringToFloat64 converts a string to a float64
func StringToInt ¶
StringToInt converts a string to a int
func StringToInt64 ¶
StringToInt64 converts a string to a int64
func WriteBytesToFile ¶
WriteBytesToFile writes the given bytes to the file with the given path
func WriteJsonObjToFile ¶
WriteJsonObjToFile writes the given JSON object to the file with the given path
func WriteStringToFile ¶
WriteStringToFile writes the given string to the file with the given path
func WriteToFile ¶
WriteToFile writes the given content to the file with the given path
Types ¶
This section is empty.