Documentation
¶
Overview ¶
Package util provides a set of common functions
Package util provides utilities related to randomization.
Index ¶
- Constants
- func EmptyThenDefault(val, defVal string) string
- func Expand(text string) (result []string)
- func Keys[T interface{}](data map[string]T) (keys []string)
- func MakeSureNotNil[T any](inter T) T
- func OKOrErrorMessage(err error) string
- func OrErrorMessage(err error, message string) string
- func PathExists(path string) (ok bool, err error)
- func String(n int) string
- func ZeroThenDefault(val, defVal int) int
Constants ¶
const ( ContentType = "Content-Type" MultiPartFormData = "multipart/form-data" Form = "application/x-www-form-urlencoded" )
ContentType is the HTTP header key
Variables ¶
This section is empty.
Functions ¶
func EmptyThenDefault ¶ added in v0.0.13
EmptyThenDefault return the default value if the val is empty
func Expand ¶ added in v0.0.12
Expand the text with brace syntax. Such as: /home/{good,bad} -> [/home/good, /home/bad]
func MakeSureNotNil ¶
func MakeSureNotNil[T any](inter T) T
MakeSureNotNil makes sure the parameter is not nil
func OKOrErrorMessage ¶ added in v0.0.13
OKOrErrorMessage returns OK or error message
func OrErrorMessage ¶ added in v0.0.13
OrErrorMessage returns error message or message
func PathExists ¶ added in v0.0.13
PathExists checks if the target path exist or not
func String ¶
String generates a random alphanumeric string, without vowels, which is n characters long. This will panic if n is less than zero. How the random string is created: - we generate random int63's - from each int63, we are extracting multiple random letters by bit-shifting and masking - if some index is out of range of alphanums we neglect it (unlikely to happen multiple times in a row)
func ZeroThenDefault ¶ added in v0.0.13
ZeroThenDefault return the default value if the val is zero
Types ¶
This section is empty.