utils

package
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrayFilter

func ArrayFilter(s []string) []string

ArrayFilter to remove empty string from slice.

func BatchInsertQuery added in v0.8.0

func BatchInsertQuery(tableName string, rowCount int, colCount int, cols ...[]string) string

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

func GetDuration(duration string) int

GetDuration to get duration in seconds. Example: `3 hr. 30 min. 20 sec.` => 12620 (seconds).

func GetMapIndex added in v0.8.0

func GetMapIndex(m map[int]string, value string) int

GetMapIndex to get index value from map.

func GetPercent added in v0.8.0

func GetPercent(top interface{}, bottom interface{}, digit ...int) float64

GetPercent to calculate percentage result with adjustable number of digit after comma.

func GetSeasonName

func GetSeasonName(m int) string

GetSeasonName to get season name (spring, summer, fall, winter).

func GetValueFromRedis added in v0.2.0

func GetValueFromRedis(client *redis.Client, key string) (value string, err error)

GetValueFromRedis to get value from redis. Assume redis is already connected.

func GetValueFromSplit

func GetValueFromSplit(str string, separator string, index int) string

GetValueFromSplit to get value from splitted string.

func InArray

func InArray(arr []string, v string) bool

InArray to get if value is in array.

func InArrayInt added in v0.8.0

func InArrayInt(array []int, value int) bool

InArrayInt to check if int value is in array int.

func ParseTime added in v0.7.3

func ParseTime(layout, str string) time.Time

ParseTime is time parser wrapper.

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

func SecondToString(seconds int) string

SecondToString to convert int seconds to string duration. Example: 12620 (seconds) => 03:30:20.

func SetSearchParams

func SetSearchParams(u *url.URL, queryObj model.Query) url.Values

SetSearchParams to set search params for search anime and manga.

func StrToFloat

func StrToFloat(strNum string) float64

StrToFloat to convert string number to float64.

func StrToNum

func StrToNum(strNum string) int

StrToNum to convert string number to integer including comma removal (1,234 -> 1234).

func StrToTime added in v0.7.3

func StrToTime(str string) time.Time

StrToTime to convert date string to time.Time type.

func URLCleaner added in v0.2.0

func URLCleaner(str string, URLType string, isNeeded ...bool) string

URLCleaner is wrapper for image and video url cleaner for easier call.

func UniqueInt added in v0.12.0

func UniqueInt(list []int) (unique []int)

UniqueInt to remove duplicate in slice.

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.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL