Documentation ¶
Index ¶
- func AnyToUint[OUT ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64](value any) (out OUT, err error)
- func AppendFile(filePath string, content string) error
- func Capitalize(s string) string
- func CheckHash(input, hash string) error
- func Contains[T comparable](slice []T, element T) bool
- func CopyFile(src string, dst string) error
- func CreateConfirmationToken(userID uint64, key string, expiresAt ...time.Time) (string, error)
- func CreateSwaggerUIPage(specURL string) string
- func CreateZeroValue(t reflect.Type) any
- func Decrypt(encryptedString string, key string) (string, error)
- func Dereferenceable(v any) bool
- func Encrypt(stringToEncrypt string, key string) (string, error)
- func Env(name string, defaultValues ...string) string
- func EscapeQuery(query string) string
- func Filter[T any](slice []T, predicate func(T) bool) []T
- func FloatPointerToUint[IN ~float32 | ~float64, OUT ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64](value *IN) (OUT, error)
- func FloatToUint[IN ~float32 | ~float64, OUT ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64](value IN) (OUT, error)
- func GenerateHash(input string) (string, error)
- func GeneratePointerChain(v any, times int) any
- func GetDereferencedType(v any) reflect.Type
- func GetStructFieldName(field reflect.StructField, fromTags ...string) string
- func If[T any](condition bool, ifTrue T, ifFalse T) T
- func IfFn[T any](condition bool, ifTrue func() T, ifFalse func() T) T
- func IntPointerToUint[IN ~int | ~int8 | ~int16 | ~int32 | ~int64, ...](value *IN) (OUT, error)
- func IntToUint[IN ~int | ~int8 | ~int16 | ~int32 | ~int64, ...](value IN) (OUT, error)
- func IsFileExists(filePath string) bool
- func IsNotAny(v any) bool
- func IsNumber(value any) bool
- func IsValidBool(v any) bool
- func IsValidEmail(v any) bool
- func IsValidFloat(v any) bool
- func IsValidInt(v any) bool
- func IsValidString(v any) bool
- func IsValidTime(v any) bool
- func IsValidUInt(v any) bool
- func Map[T any, R any](slice []T, mapper func(T) R) []R
- func MapKeys[K comparable, V any](m map[K]V) []K
- func MapValues[K comparable, V any](m map[K]V) []V
- func MkDirs(dirs ...string) error
- func Must[T any](value T, err error) T
- func ParseHJSON[T any](input []byte) (T, error)
- func ParseStructFieldTag(field reflect.StructField, tagName string) map[string]string
- func Pick(obj any, path string, defaultValues ...any) any
- func RandomString(length int) string
- func ReadCloserToString(rc io.ReadCloser) (string, error)
- func SecureRandomBytes(length int) ([]byte, error)
- func SendRequest[T any](method, url string, headers map[string]string, requestBody io.Reader) (T, error)
- func SliceEqual[T comparable](slice1 []T, slice2 []T) bool
- func SliceInsertBeforeElement[T comparable](slice []T, newElement T, checkIndexFn func(element T) bool) []T
- func Title(s string) string
- func ToSnakeCase(s string) string
- func UintPointerToUint[IN ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64, ...](value *IN) (OUT, error)
- func WriteFile(filePath string, content string) error
- type ConfirmationData
- type HashConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendFile ¶
AppendFile appends the given content to the given file path. If the file does not exist, it creates the file.
func Contains ¶
func Contains[T comparable](slice []T, element T) bool
func CreateConfirmationToken ¶
func CreateSwaggerUIPage ¶
CreateSwaggerUIPage creates a simple HTML page that serves the Swagger UI
func CreateZeroValue ¶
CreateZeroValue creates a zero value of a type.
func Dereferenceable ¶
Dereferenceable returns true if the value is dereferenceable.
func EscapeQuery ¶
EscapeQuery escapes the query string to be used in a regular expression. copied from ent test
func FloatPointerToUint ¶
func FloatToUint ¶
func GenerateHash ¶
func GeneratePointerChain ¶
GeneratePointerChain creates a chain of pointers by taking the address of the original value 'v' 'times' number of times. It returns the final value in the pointer chain.
func GetDereferencedType ¶
GetDereferencedType returns the dereferenced type of a value 'v'
func GetStructFieldName ¶
func GetStructFieldName(field reflect.StructField, fromTags ...string) string
GetStructFieldName returns the name of a struct field based on the provided reflect.StructField and tag name.
If no tag name is provided, it defaults to "json". If the field name is "-", it returns an empty string.
func IntPointerToUint ¶
func IsFileExists ¶
IsFileExists checks if the given file path exists.
func IsValidBool ¶
IsValidBool check if the given value is a valid boolean.
func IsValidEmail ¶
IsValidEmail check if the given value is a valid email.
func IsValidFloat ¶
IsValidFloat check if the given value is a valid float.
func IsValidInt ¶
IsValidInt check if the given value is a valid integer.
func IsValidString ¶
IsValidString check if the given value is a valid string.
func IsValidTime ¶
IsValidTime check if the given value is a valid time.
func IsValidUInt ¶
IsValidUInt check if the given value is a valid unsigned integer.
func MapKeys ¶
func MapKeys[K comparable, V any](m map[K]V) []K
func MapValues ¶
func MapValues[K comparable, V any](m map[K]V) []V
func ParseHJSON ¶
ParseHJSON parses the given input byte slice as HJSON and returns the result as type T.
func ParseStructFieldTag ¶
func ParseStructFieldTag(field reflect.StructField, tagName string) map[string]string
ParseStructFieldTag parses the struct field tag and returns a map of tag key-value pairs.
For example, if the struct tag is: `fs:"name=title;label=Title;multiple;unique;optional;sortable;filterable;size=255"`, then ParseStructFieldTag(field, "fs") will return: { "name": "title", "label": "Title", "multiple": "", "unique": "", "optional": "", "sortable": "", "filterable": "", "size": "255", }
func RandomString ¶
func ReadCloserToString ¶
func ReadCloserToString(rc io.ReadCloser) (string, error)
func SecureRandomBytes ¶
SecureRandomBytes returns the requested number of bytes using crypto/rand
func SendRequest ¶
func SliceEqual ¶
func SliceEqual[T comparable](slice1 []T, slice2 []T) bool
func SliceInsertBeforeElement ¶
func SliceInsertBeforeElement[T comparable](slice []T, newElement T, checkIndexFn func(element T) bool) []T
func ToSnakeCase ¶
ToSnakeCase converts a string from capital case to snake case
For example: "ToSnakeCase" -> "create_snake_case" "userID" -> "user_id" "HTTPResponse" -> "http_response"
func UintPointerToUint ¶
Types ¶
type ConfirmationData ¶
func ParseConfirmationToken ¶
func ParseConfirmationToken(token, key string) (*ConfirmationData, error)