Documentation ¶
Index ¶
- Constants
- func CreateDir(dirName string) error
- func DateDifferenceInDays(t1 time.Time, t2 time.Time) float64
- func EncodeImageAsDataUrl(img image.Image) (*string, error)
- func ExecuteCommand(command string, env []string, args ...string) (outStr string, errStr string, err error)
- func ExitIfError(err error)
- func FileExists(fileName string) bool
- func FindString(slice []string, val string) (int, bool)
- func FormatBytes(b int64) string
- func GetFieldInteger[T any](e *T, field string) int
- func GetFieldString[T any](e *T, field string) string
- func GetSimpleDateTimeString() string
- func IntArrayToString(a []int, delim string) string
- func LogN(base float64, number float64) float64
- func MaxInt(nums ...int) int
- func Merge[T any](dst *T, src *T) error
- func MinInt(nums ...int) int
- func NewTime(year, month, day int) time.Time
- func ParseInt(v interface{}) (int, error)
- func PrintMemUsage()
- func ReadFileToString(fileName string) (*string, error)
- func RemoveDuplicateStr(strSlice []string) []string
- func RemoveFirstStr(s []string, r string) []string
- func RemoveWhiteSpace(s string) string
- func Schedule(ctx context.Context, p time.Duration, o time.Duration, immediate bool, ...) time.Duration
- func SliceFindElement[T comparable](slice []T, val T) (int, bool)
- func SliceFromMap[K comparable, V any](m map[K]*V) []*V
- func SliceFromMapKeys[K comparable, V any](m map[K]*V) []K
- func SliceJoinElems[T any](s []T, delim string) string
- func SliceRemoveManyByIndex[T comparable](s []T, indicesToRemove []int) ([]T, error)
- func SliceRemoveOneByIndex[T any](s []T, i int) ([]T, error)
- func SliceWithIdsToMap[V any](s []*V) map[int]*V
- func SliceWithPointersFromSliceWithValues[T any](values []T) []*T
- func SliceWithValuesFromSliceWithPointers[T any](values []*T) []T
- func SnakeCaseToCamelCase(inputUnderScoreStr string) string
- func StringToSnakeCase(s string) string
- func StripSpecialChars(s string) string
- func Substr(input string, start int, length int) string
- func UnzipSingleFileArchive(file []byte) ([]byte, error)
- func UsesOnlyLetterAndNumbers(s string) bool
- func ZipSingleFile(name string, content []byte) (*bytes.Buffer, error)
Constants ¶
const SimpleDateFormat = "02/01/2006"
Variables ¶
This section is empty.
Functions ¶
func DateDifferenceInDays ¶
DateDifferenceInDays returns the difference in days (including fractions) from t1 to t2
func ExecuteCommand ¶
func ExitIfError ¶
func ExitIfError(err error)
func FileExists ¶
func FindString ¶
Find takes a slice and looks for an element in it. If found it will return it's key, otherwise it will return -1 and a bool of false.
func FormatBytes ¶
Format byte count value (e.g. file size) to human-readable form
func GetFieldInteger ¶
func GetFieldString ¶
func GetSimpleDateTimeString ¶
func GetSimpleDateTimeString() string
GetSimpleDateTimeString returns a date string in the format 2006-01-02-15-04-05
func IntArrayToString ¶
func ReadFileToString ¶
func RemoveDuplicateStr ¶
func RemoveFirstStr ¶
func RemoveWhiteSpace ¶
Remove all unicode white space from string
func Schedule ¶
func Schedule(ctx context.Context, p time.Duration, o time.Duration, immediate bool, f func(time.Time)) time.Duration
Schedule calls function `f` with a period `p` offset by `o`. Run once immediately if immediate is set.
func SliceFindElement ¶
func SliceFindElement[T comparable](slice []T, val T) (int, bool)
Takes a slice and looks for an element in it. If found it will return its index, otherwise it will return -1 and a bool of false.
func SliceFromMap ¶
func SliceFromMap[K comparable, V any](m map[K]*V) []*V
Generate a slice from a map
func SliceFromMapKeys ¶
func SliceFromMapKeys[K comparable, V any](m map[K]*V) []K
Generate a slice from a map's keys (generic)
func SliceJoinElems ¶
Joins the elements of the slice with separator delim
func SliceRemoveManyByIndex ¶
func SliceRemoveManyByIndex[T comparable](s []T, indicesToRemove []int) ([]T, error)
Removes items at the given positions from slice s
func SliceRemoveOneByIndex ¶
Removes item at position i from slice s
func SliceWithIdsToMap ¶
Generate a map from a slice with elements having an ID property
func SliceWithPointersFromSliceWithValues ¶
func SliceWithPointersFromSliceWithValues[T any](values []T) []*T
Convert a slice of values to a slice of value pointers
func SliceWithValuesFromSliceWithPointers ¶
func SliceWithValuesFromSliceWithPointers[T any](values []*T) []T
Convert a slice of value pointers to a slice of values
func SnakeCaseToCamelCase ¶
func StringToSnakeCase ¶
func StripSpecialChars ¶
func Substr ¶
NOTE: this isn't multi-Unicode-codepoint aware, like specifying skintone or
gender of an emoji: https://unicode.org/emoji/charts/full-emoji-modifiers.html
func UnzipSingleFileArchive ¶
Types ¶
This section is empty.