Documentation ¶
Index ¶
- func ArrayFilter(s []string) []string
- func BatchInsertQuery(tableName string, rowCount int, colCount int, cols ...[]string) string
- func GetCurrentSeason() string
- func GetDuration(duration string) int
- func GetMapIndex(m map[int]string, value string) int
- func GetPercent(top interface{}, bottom interface{}, digit ...int) float64
- func GetSeasonName(m int) string
- func GetValueFromRedis(client *redis.Client, key string) (value string, err error)
- func GetValueFromSplit(str string, separator string, index int) string
- func ImageURLCleaner(str string) string
- func InArray(arr []string, v string) bool
- func InArrayInt(array []int, value int) bool
- func ParseTime(layout, str string) time.Time
- func SaveToRedis(client *redis.Client, key string, value interface{}, expiredTime time.Duration) error
- func SecondToString(seconds int) string
- func SetSearchParams(u *url.URL, queryObj model.Query) url.Values
- func StrToFloat(strNum string) float64
- func StrToNum(strNum string) int
- func StrToTime(str string) time.Time
- func URLCleaner(str string, URLType string, isNeeded ...bool) string
- func UniqueInt(list []int) (unique []int)
- func UnmarshalFromRedis(client *redis.Client, key string, model interface{}) (isFound bool, err error)
- func VideoURLCleaner(str string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArrayFilter ¶
ArrayFilter to remove empty string from slice.
func BatchInsertQuery ¶ added in v0.8.0
BatchInsertQuery to create raw batch insert query.
func GetCurrentSeason ¶
func GetCurrentSeason() string
GetCurrentSeason to get current season (spring, summer, fall, winter).
func GetDuration ¶ added in v0.8.0
GetDuration to get duration in seconds. Example: `3 hr. 30 min. 20 sec.` => 12620 (seconds).
func GetMapIndex ¶ added in v0.8.0
GetMapIndex to get index value from map.
func GetPercent ¶ added in v0.8.0
GetPercent to calculate percentage result with adjustable number of digit after comma.
func GetSeasonName ¶
GetSeasonName to get season name (spring, summer, fall, winter).
func GetValueFromRedis ¶ added in v0.2.0
GetValueFromRedis to get value from redis. Assume redis is already connected.
func GetValueFromSplit ¶
GetValueFromSplit to get value from splitted string.
func ImageURLCleaner ¶
ImageURLCleaner to clean dirty image url. Example: https://cdn.myanimelist.net/r/80x120/images/manga/3/214566.jpg?s=48212bcd0396d503a01166149a29c67e => https://cdn.myanimelist.net/images/manga/3/214566.jpg https://cdn.myanimelist.net/r/76x120/images/userimages/6098374.jpg?s=4b8e4f091fbb3ecda6b9833efab5bd9b => https://cdn.myanimelist.net/images/userimages/6098374.jpg https://cdn.myanimelist.net/r/76x120/images/questionmark_50.gif?s=8e0400788aa6af2a2f569649493e2b0f => empty string
func InArrayInt ¶ added in v0.8.0
InArrayInt to check if int value is in array int.
func SaveToRedis ¶ added in v0.2.0
func SaveToRedis(client *redis.Client, key string, value interface{}, expiredTime time.Duration) error
SaveToRedis to save value to redis. Assume redis is already connected.
func SecondToString ¶ added in v0.8.0
SecondToString to convert int seconds to string duration. Example: 12620 (seconds) => 03:30:20.
func SetSearchParams ¶
SetSearchParams to set search params for search anime and manga.
func StrToFloat ¶
StrToFloat to convert string number to float64.
func StrToNum ¶
StrToNum to convert string number to integer including comma removal (1,234 -> 1234).
func URLCleaner ¶ added in v0.2.0
URLCleaner is wrapper for image and video url cleaner for easier call.
func UnmarshalFromRedis ¶ added in v0.2.0
func UnmarshalFromRedis(client *redis.Client, key string, model interface{}) (isFound bool, err error)
UnmarshalFromRedis to unmarshal redis value to model.
func VideoURLCleaner ¶
VideoURLCleaner to clean dirty video url. Example: https://www.youtube.com/embed/qig4KOK2R2g?enablejsapi=1&wmode=opaque&autoplay=1 => https://www.youtube.com/watch?v=qig4KOK2R2g https://www.youtube.com/embed/j2hiC9BmJlQ?enablejsapi=1&wmode=opaque&autoplay=1 => https://www.youtube.com/watch?v=j2hiC9BmJlQ
Types ¶
This section is empty.