utils

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 12 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

type ArgumentsQuery added in v0.4.0

type ArgumentsQuery struct {
	// contains filtered or unexported fields
}

ArgumentsQuery to check whether arg value is null

func Arguments added in v0.4.0

func Arguments(ctx context.Context) (ret ArgumentsQuery)

Arguments query to check whether args value is null. https://github.com/99designs/gqlgen/issues/866

func (ArgumentsQuery) Field added in v0.4.0

func (a ArgumentsQuery) Field(name string) ArgumentsQuery

Field select field by name, returns a new query.

func (ArgumentsQuery) Index added in v0.4.0

func (a ArgumentsQuery) Index(index int) ArgumentsQuery

Index select field by array index, returns a new query.

func (ArgumentsQuery) IsNull added in v0.4.0

func (a ArgumentsQuery) IsNull() bool

IsNull return whether selected field value is null.

Jump to

Keyboard shortcuts

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