Documentation
¶
Index ¶
- Constants
- Variables
- func CloseBody(Body io.ReadCloser)
- func CloseDB(sql *sql.DB)
- func CloseFile(file *os.File)
- func Convert(source interface{}, destination interface{}) (err error)
- func Eq(val1, val2, tRes, fRes interface{}) interface{}
- func EqualString(str, subStr string) bool
- func ErrorHandler(err error)
- func GetEnvBool(key string, val bool) bool
- func GetEnvFloat64(key string, val float64) float64
- func GetEnvInt64(key string, val int64) int64
- func GetEnvString(key, defaultVal string) string
- func GetEnvTimeDuration(key string, val time.Duration) time.Duration
- func Gt(val1, val2, tRes, fRes interface{}) interface{}
- func Gte(val1, val2, tRes, fRes interface{}) interface{}
- func Highlight(str, searchText, prefix, suffix string) string
- func IsContainInt(str int, data []int) bool
- func IsContainInt64(str int64, data []int64) bool
- func IsContainString(str string, data []string) bool
- func IsContainUint(str uint, data []uint) bool
- func IsContainUint64(str uint64, data []uint64) bool
- func LogPrint(args ...interface{})
- func Lt(val1, val2, tRes, fRes interface{}) interface{}
- func Lte(val1, val2, tRes, fRes interface{}) interface{}
- func MergeArrayInterfaces(models ...[]interface{}) (res []interface{})
- func Ne(val1, val2, tRes, fRes interface{}) interface{}
- func PasswordValidation(s string) (err error)
- func PrettyPrint(data interface{})
- func RandomString(length int, kind kindOfCase) string
- func Slugify(s string) string
- func SplitTime(data interface{}) (hours, minutes, seconds int, err error)
- func StringToUintArr(req []string) (res []uint)
- func Version() string
- func WeekRange(year, week int) (start, end time.Time)
- func WeekRangeWithTime(tm time.Time) (start, end time.Time)
- func WeekStart(year, week int) time.Time
- func WeekStartWithTime(tm time.Time) time.Time
Constants ¶
const ( LowerCase kindOfCase = "lower" UpperCase kindOfCase = "upper" Alphabet kindOfCase = "alphabet" DigitCase kindOfCase = "digit" SymbolCase kindOfCase = "symbol" AllCase kindOfCase = "all" Default kindOfCase = "" )
Variables ¶
var ReDupSeparatorChar = regexp.MustCompile(fmt.Sprintf("%s{2,}", SeparatorForRe))
ReDupSeparatorChar match duplicate separator string
var ReInValidChar = regexp.MustCompile(fmt.Sprintf("[^%sa-zA-Z0-9]", SeparatorForRe))
ReInValidChar match invalid slug string
var Separator = "-"
Separator separator between words
var SeparatorForRe = regexp.QuoteMeta(Separator)
SeparatorForRe for regexp
Functions ¶
func CloseBody ¶
func CloseBody(Body io.ReadCloser)
CloseBody for secure close io ReadCloser with message error if error
func Convert ¶
func Convert(source interface{}, destination interface{}) (err error)
Convert for convert from map[string]interface{} to struct or reverse or array of them
func Eq ¶ added in v1.0.1
func Eq(val1, val2, tRes, fRes interface{}) interface{}
Eq utils function
Eq means equal
Used to return the true value according to the value you want to compare.
The parameters consist of 4 data types interface{} where the first and second parameters are the values to be compared
while for the third value is the value that will be returned when the condition is true and the fourth parameter is for the value when the condition is false
Example:
exp1 := Eq("eat", "sleep", 100, 50) // exp1 = 50
exp2 := Eq("eat", "eat", 100, 50) // exp2 = 100
func EqualString ¶
EqualString for cek if string contain substring example : EqualString("Report Service", "report") will return true.
func ErrorHandler ¶
func ErrorHandler(err error)
ErrorHandler for print error message to console with engine name if error != nil
func GetEnvFloat64 ¶ added in v1.1.8
GetEnvFloat64 for get env variables type int64 in golang
func GetEnvInt64 ¶ added in v1.1.8
GetEnvInt64 for get env variables type int64 in golang
func GetEnvString ¶
GetEnvString for get env type string
func GetEnvTimeDuration ¶
GetEnvTimeDuration for get env variables type time duration in golang
func Gt ¶ added in v1.0.1
func Gt(val1, val2, tRes, fRes interface{}) interface{}
Gt func for if not equals
Gt means Greater Than
Used to return the true value according to the value you want to compare.
The parameters consist of 4 data types interface{} where the first and second parameters are the values to be compared
while for the third value is the value that will be returned when the condition is true and the fourth parameter is for the value when the condition is false
Example:
exp1 := Gt(99, 100, "yes", "no") // exp1 = no
exp2 := Gt(99, 70, "yes", "no) // exp2 = yes
func Gte ¶ added in v1.0.1
func Gte(val1, val2, tRes, fRes interface{}) interface{}
Gte func for if not equals
Gte means Greater Than Equal
Used to return the true value according to the value you want to compare.
The parameters consist of 4 data types interface{} where the first and second parameters are the values to be compared
while for the third value is the value that will be returned when the condition is true and the fourth parameter is for the value when the condition is false
Example:
exp1 := Gte(99, 100, "yes", "no") // exp1 = no
exp2 := Gte(99, 70, "yes", "no) // exp2 = yes
exp3 := Gte(99, 99, "yes", "no) // exp3 = yes
func IsContainInt ¶ added in v1.0.1
IsContainInt Check if array string contain int
func IsContainInt64 ¶ added in v1.0.1
IsContainInt64 Check if array string contain int64
func IsContainString ¶
IsContainString Check if array string contain string
func IsContainUint ¶ added in v1.0.1
IsContainUint Check if array string contain uint
func IsContainUint64 ¶ added in v1.0.1
IsContainUint64 Check if array string contain uint64
func LogPrint ¶
func LogPrint(args ...interface{})
LogPrint for print message for debug with engine name
func Lt ¶ added in v1.0.1
func Lt(val1, val2, tRes, fRes interface{}) interface{}
Lt func for if not equals
Lt means Less Than
Used to return the true value according to the value you want to compare.
The parameters consist of 4 data types interface{} where the first and second parameters are the values to be compared
while for the third value is the value that will be returned when the condition is true and the fourth parameter is for the value when the condition is false
Example:
exp1 := Lt(99, 100, "yes", "no") // exp1 = yes
exp2 := Lt(99, 70, "yes", "no) // exp2 = no
func Lte ¶ added in v1.0.1
func Lte(val1, val2, tRes, fRes interface{}) interface{}
Lte func for if not equals
Lte means Less Than Equal
Used to return the true value according to the value you want to compare.
The parameters consist of 4 data types interface{} where the first and second parameters are the values to be compared
while for the third value is the value that will be returned when the condition is true and the fourth parameter is for the value when the condition is false
Example:
exp1 := Lte(99, 100, "yes", "no") // exp1 = yes
exp2 := Lte(99, 70, "yes", "no) // exp2 = no
exp3 := Lte(99, 99, "yes", "no) // exp3 = yes
func MergeArrayInterfaces ¶ added in v1.1.5
func MergeArrayInterfaces(models ...[]interface{}) (res []interface{})
MergeArrayInterfaces This function used to merge [][]interface{} to []interface{} This function is variadic function which use two dimension array of interface{}
func Ne ¶ added in v1.0.1
func Ne(val1, val2, tRes, fRes interface{}) interface{}
Ne func for if not equals
Ne means Not Equal
Used to return the true value according to the value you want to compare.
The parameters consist of 4 data types interface{} where the first and second parameters are the values to be compared
while for the third value is the value that will be returned when the condition is true and the fourth parameter is for the value when the condition is false
Example:
exp1 := Ne("eat", "sleep", 100, 50) // exp1 = 100
exp2 := Ne("eat", "eat", 100, 50) // exp2 = 50
func PasswordValidation ¶ added in v1.1.9
PasswordValidation for validate string must have uppercase, special char and number
func PrettyPrint ¶
func PrettyPrint(data interface{})
PrettyPrint for print struct/map/array to console as indent view
func RandomString ¶
RandomString is a utils for generate random string with param length of string and type of string kind = (lower/upper/digit/symbol/all) or default is lower+upper+digit
func Slugify ¶ added in v1.1.1
Slugify implements make a pretty slug from the given text. e.g. Slugify("kožušček hello world") => "kozuscek-hello-world"
func StringToUintArr ¶
StringToUintArr for convert array of string number to unit array
func WeekRangeWithTime ¶ added in v1.1.6
WeekRangeWithTime Get datetime start and end from week in year
Types ¶
This section is empty.