utils

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 20, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DuplicateError

func DuplicateError(err error, size int) []error

func FileExists

func FileExists(path string) (bool, error)

FileExists returns true if the given path exists

func FindField

func FindField(m map[string]interface{}, qualifiedField string) (interface{}, bool)

FindField traverses a json map, searching for the field matching the qualified field string provided.

For example: a qualifiedField of "foo" returns value of the "foo" key in the provided map. A qualifiedField of "foo.bar" will find the "foo" value, and if it is a map[string]interface{}, will return the "bar" value of that map. Returns the value and true if the value was found. Returns nil and false if the value was not found, or if one of the intermediate values was not a map[string]interface{}

func GenerateRandomKey

func GenerateRandomKey(l int) (string, error)

func GenerateRandomPassword

func GenerateRandomPassword(l int) (string, error)

func GetYMDFromDatabaseDate

func GetYMDFromDatabaseDate(dateString string) string

func Includes added in v0.2.0

func Includes[T comparable](arr []T, against T) bool

func IsBannedPassword

func IsBannedPassword(password string) bool

IsBannedPassword returns true if the password matches one from the banned password list.

func MD5FromBytes

func MD5FromBytes(data []byte) string

func MD5FromFilePath

func MD5FromFilePath(filePath string) (string, error)

func MD5FromString

func MD5FromString(str string) string

func ParseDateStringAsFormat

func ParseDateStringAsFormat(dateString string, format string) (string, error)

func ParseDateStringAsTime

func ParseDateStringAsTime(dateString string) (time.Time, error)

func ProcessSlice added in v0.2.0

func ProcessSlice[T comparable](current []T, added []T, removed []T) []T

func ResolveEnum

func ResolveEnum(value sql.NullString, out interface{}) bool

func ResolveEnumString

func ResolveEnumString(value string, out interface{}) bool

func SliceCompare added in v0.2.0

func SliceCompare[T comparable](subject []T, against []T) (added []T, missing []T)

func StrPtrToString added in v0.2.0

func StrPtrToString(val *string) string

func StringToStrPtr added in v0.2.0

func StringToStrPtr(val string) *string

func Touch

func Touch(path string) error

Touch creates an empty file at the given path if it doesn't already exist

Types

This section is empty.

Jump to

Keyboard shortcuts

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