Documentation
¶
Index ¶
- func Contains[T comparable](s []T, e T) bool
- func DurationOrDefault(value, defaultValue time.Duration) time.Duration
- func EncodeURLParams(q any) string
- func Filter[T any](ss []T, test func(T, int) bool) (res []T)
- func Find[T any](ss []T, test func(T, int) bool) (res T)
- func FirstValue(values ...string) string
- func Foreach[T any](ss []T, apply func(T, int) T) []T
- func GetContentTypeFromURL(fileURL string) string
- func GetExtensionFromContentType(contentType string) string
- func HasMatch(text string, patterns []string) bool
- func Hash(s string, l int) string
- func If[T any](condition bool, trueValue, falseValue T) T
- func IntOrDefault(value, defaultValue int) int
- func Map[T, V any](ts []T, fn func(T) V) []V
- func Matches(pattern string, str string) (map[string]string, error)
- func MergeObjects[T any](objA *T, objB T)
- func ParseInt(s string) int
- func ParseJson[T interface{}](jsonStr string) (T, error)
- func ParseTimeout(s string) time.Duration
- func RandomInt(min, max int) int
- func RandomString(length int) string
- func RegexSubMatch(r *regexp.Regexp, str string) map[string]string
- func Retry[T any](ctx context.Context, retries int, delay time.Duration, ...) (T, error)
- func Sleep(ctx context.Context, delay time.Duration)
- func SleepRandom(ctx context.Context, min, max int)
- func StartsWith(s, prefix string) bool
- func StringOrDefault(value, defaultValue string) string
- func StringToIntOrDefault(value string, defaultValue int) int
- func StripNonAlphanumeric(s string) string
- func StripWhitespace(s string) string
- func Try(f func(), logger ...log.LoggerInterface)
- func TryCatch(f func(), catch func(e error, stackTrace string))
- func TryReturn[T any](f func() (T, error)) (res T, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
func Contains[T comparable](s []T, e T) bool
func DurationOrDefault ¶ added in v1.3.0
func EncodeURLParams ¶
func FirstValue ¶
func GetContentTypeFromURL ¶ added in v1.8.4
GetContentTypeFromURL tries to infer content type from file extension in URL
func GetExtensionFromContentType ¶ added in v1.8.4
GetExtensionFromContentType returns file extension based on content type
func IntOrDefault ¶
func MergeObjects ¶ added in v1.3.0
func MergeObjects[T any](objA *T, objB T)
MergeObjects merges two objects of the same type. It will iterate over the fields of the object and set the value of objA to the value of objB if the value of objA is the zero value.
func ParseTimeout ¶ added in v1.0.3
func RandomString ¶
func SleepRandom ¶
func StartsWith ¶
func StringOrDefault ¶
func StringToIntOrDefault ¶
func StripNonAlphanumeric ¶ added in v1.8.9
func StripWhitespace ¶
func Try ¶
func Try(f func(), logger ...log.LoggerInterface)
Try wraps a goroutine and will recover from a panic If a logger is provided, it will log the error using the given logger
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.