utils

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2022 License: MIT Imports: 11 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 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 ResolveEnum

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

func ResolveEnumString

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

func StrFilter

func StrFilter(vs []string, f func(string) bool) []string

func StrInclude

func StrInclude(vs []string, t string) bool

func StrIndex

func StrIndex(vs []string, t string) int

func StrMap

func StrMap(vs []string, f func(string) string) []string

func StrSliceCompare

func StrSliceCompare(subject []string, against []string) (added []string, missing []string)

StrSliceCompare returns a slice of strings that are present in subject but not in against - in the added slice - and a slice of strings that are not present in subject, and are in against - in the missing slice.

func Touch

func Touch(path string) error

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

func UUIDInclude added in v0.1.0

func UUIDInclude(vs []uuid.UUID, t uuid.UUID) bool

func UUIDIndex added in v0.1.0

func UUIDIndex(vs []uuid.UUID, t uuid.UUID) int

func UUIDSliceCompare added in v0.1.0

func UUIDSliceCompare(subject []uuid.UUID, against []uuid.UUID) (added []uuid.UUID, missing []uuid.UUID)

UUIDSliceCompare returns a slice of UUIDs that are present in subject but not in against - in the added slice - and a slice of strings that are not present in subject, and are in against - in the missing slice.

Types

This section is empty.

Jump to

Keyboard shortcuts

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