Documentation ¶
Index ¶
- Constants
- func ArrayStringPointerToArrayInt64(s *[]*string) []int64
- func BoolPointerToBool(b *bool) bool
- func BoolToString(b bool) string
- func Contains[T comparable](a []T, x T) bool
- func ContainsInt64(a []int64, x int64) bool
- func ContainsString(a []string, x string) bool
- func ConvertSlice[T1 any, T2 any](in []T1, converter func(T1) T2) []T2
- func DeleteByValue[T comparable](a []T, x T) []T
- func Difference[T comparable](slice1 []T, slice2 []T) []T
- func DifferenceInt64(slice1 []int64, slice2 []int64) []int64
- func DifferenceString(slice1 []string, slice2 []string) []string
- func DoHTTPRequest[T httpResponse](ctx context.Context, httpClient *http.Client, httpRequest *http.Request) (respStatusCode int, respBody *T, err error)
- func Dump(i interface{}) string
- func DumpIncomingContext(c context.Context) string
- func DumpOutGoingContext(c context.Context) string
- func EscapeQuote(in string) string
- func FindDifferencesFromSlices[T comparable](slices ...[]T) []T
- func Float64PointerToFloat64(f *float64) float64
- func FormatMoney(value decimal.Decimal, currencyCode string) string
- func FormatTimeRFC3339(t *time.Time) (s string)
- func FormatToIndonesianMoney(dec decimal.Decimal) string
- func FormatToWesternIndonesianTime(layout string, t *time.Time) string
- func GenerateID() int64
- func GeneratePushNotificationMediaURL(cdnURL, mediaSrcURL, imageType string) string
- func GenerateRandomAlphanumeric(n int) string
- func GenerateRandomBytes(n int) ([]byte, error)
- func GenerateRandomString(n int) (string, error)
- func GenerateRandomStringURLSafe(n int) (string, error)
- func GenerateULIDFromTime(t time.Time) string
- func GenerateUUID() string
- func GetCronNextAt(cronTab string) string
- func GetDifferenceDaysForHumans(startsAt time.Time, endsAt time.Time) string
- func GetIDFromSlug(slug string) string
- func GraphQLIDPointerToInt32(id *graphql.ID) int32
- func GraphQLIDPointerToInt64(id *graphql.ID) int64
- func GraphQLIDPointerToString(id *graphql.ID) string
- func GraphQLIDToInt32(id graphql.ID) int32
- func GraphQLIDToInt64(id graphql.ID) int64
- func GraphQLIDToString(id graphql.ID) string
- func Int32PointerToInt32(i *int32) int32
- func Int32PointerToInt64(i *int32) int64
- func Int64MillisToPointerTime(millis int64) *time.Time
- func Int64MillisToTime(millis int64) time.Time
- func Int64PointerToInt64(i *int64) int64
- func Int64ToGraphQLID(i int64) graphql.ID
- func Int64ToString(i int64) string
- func Int64WithLimit(input int64, limit int64) int64
- func Int64WithMinAndMaxLimit(input, min, max int64) int64
- func InterfaceBytesToInt64(i interface{}) int64
- func InterfaceBytesToType[T any](i interface{}) (out T)
- func IsEmailValid(email string) bool
- func IsNumeric(s string) bool
- func IsSameSliceIgnoreOrder(a, b []int64) bool
- func IsURLReachable(url string) bool
- func IsUniqueSliceItem[T comparable](data []T) bool
- func JoinURL(baseURL string, pathElements ...string) (string, error)
- func LowerMapStringKey(v map[string]interface{}) map[string]interface{}
- func MapValuesToOrderedSlice[K comparable, V any](src map[K]V, keysOrder []K) (orderedMapValues []V)
- func MyCaller(skip int) string
- func Offset(page, limit int64) int64
- func PaginateSlice[T comparable](data []T, page, size int64) []T
- func ParseDurationWithDefault(in string, defaultDuration time.Duration) time.Duration
- func RegexEmail() *regexp.Regexp
- func Retry(attempts int, sleep time.Duration, fn func() error) error
- func SliceAtoi(s []string) ([]int, error)
- func SlicePointerInt32PointerToSliceInt64(i *[]*int32) (result []int64)
- func StandardizeSpaces(s string) string
- func StringMillisToPointerTime(millis string) *time.Time
- func StringMillisToTime(millis string) time.Time
- func StringPointerToFloat64(s *string) float64
- func StringPointerToInt64(s *string) int64
- func StringPointerToString(s *string) string
- func StringToBool(s string) bool
- func StringToInt64(s string) int64
- func StringToInt64WithDefault(s string, d int64) int64
- func StripHTML(s string) string
- func Ternary(condition bool, a, b interface{}) interface{}
- func TimeFromObjectIDHex(s string) (t time.Time, err error)
- func ToByte(i interface{}) []byte
- func TrimSpacePointerString(s *string)
- func TruncateString(str string, num int) string
- func UnescapeString(str string) (ustr string)
- func Unique[T comparable](elements []T) (result []T)
- func UniqueInt64(elements []int64) []int64
- func UniqueString(elements []string) []string
- func ValueOfPointer[T comparable](i *T) T
- func ValueOrDefault[T comparable](value, defaultValue T) T
- type Hook
- func (hook *Hook) AddTag(key, value string)
- func (hook *Hook) Fire(entry *logrus.Entry) error
- func (hook *Hook) Flush()
- func (hook *Hook) Levels() []logrus.Level
- func (hook *Hook) SetEnvironment(environment string)
- func (hook *Hook) SetFlushTimeout(timeout time.Duration)
- func (hook *Hook) SetPrefix(prefix string)
- func (hook *Hook) SetRelease(release string)
- func (hook *Hook) SetTags(tags map[string]string)
- type RetryStopper
Constants ¶
const ( // BigPicture :nodoc: BigPicture = "big_picture" // LargeIcon :nodoc: LargeIcon = "large_icon" // IOSAttachment :nodoc: IOSAttachment = "ios_attahcment" )
Variables ¶
This section is empty.
Functions ¶
func ArrayStringPointerToArrayInt64 ¶
ArrayStringPointerToArrayInt64 :nodoc:
func Contains ¶ added in v1.21.0
func Contains[T comparable](a []T, x T) bool
Contains tells whether slice A contains x.
func ContainsInt64 ¶
ContainsInt64 tells whether a slice contains x.
func ContainsString ¶
ContainsString tells whether a slice contains x.
func ConvertSlice ¶ added in v1.38.0
ConvertSlice can change slice data type or even manipulate the data using converter func
func DeleteByValue ¶ added in v1.28.0
func DeleteByValue[T comparable](a []T, x T) []T
DeleteByValue use for delete value in slice
func Difference ¶ added in v1.21.0
func Difference[T comparable](slice1 []T, slice2 []T) []T
Difference get discrepancies between 2 slices
func DifferenceInt64 ¶
DifferenceInt64 :nodoc:
func DifferenceString ¶
DifferenceString :nodoc:
func DoHTTPRequest ¶ added in v1.35.0
func DoHTTPRequest[T httpResponse](ctx context.Context, httpClient *http.Client, httpRequest *http.Request) (respStatusCode int, respBody *T, err error)
DoHTTPRequest generic do http request using ctxhttp
func DumpIncomingContext ¶
DumpIncomingContext :nodoc:
func DumpOutGoingContext ¶
DumpOutGoingContext :nodoc:
func FindDifferencesFromSlices ¶ added in v1.32.0
func FindDifferencesFromSlices[T comparable](slices ...[]T) []T
FindDifferencesFromSlices find item that not exists in all slices but exists in one or more of them
func Float64PointerToFloat64 ¶
Float64PointerToFloat64 :nodoc:
func FormatMoney ¶ added in v1.9.0
FormatMoney format money by currency code (ISO 4217)
func FormatTimeRFC3339 ¶
FormatTimeRFC3339 Format time according to RFC3339Nano
func FormatToIndonesianMoney ¶ added in v1.7.1
FormatToIndonesianMoney format money into Indonesian example: Rp10.000.000
func FormatToWesternIndonesianTime ¶ added in v1.7.1
FormatToWesternIndonesianTime format to western indonesian time expected format: 12 April 2020 14:30 WIB
func GeneratePushNotificationMediaURL ¶ added in v1.1.0
GeneratePushNotificationMediaURL Generates manipulated media URL for push notification purpose e.g. GeneratePushNotificationMediaURL("http://mycdn.com", "http://my.image.com/image/upload/v123/image.jpg", LargeIcon) => http://mycdn.com/image/upload/v123/image.jpg
func GenerateRandomAlphanumeric ¶ added in v1.4.0
GenerateRandomAlphanumeric Generate random alphanumeric character adapted from https://stackoverflow.com/questions/22892120/how-to-generate-a-random-string-of-a-fixed-length-in-go
func GenerateRandomBytes ¶
GenerateRandomBytes adapted from https://elithrar.github.io/article/generating-secure-random-numbers-crypto-rand/ GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func GenerateRandomString ¶
GenerateRandomString returns a securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func GenerateRandomStringURLSafe ¶
GenerateRandomStringURLSafe returns a URL-safe, base64 encoded securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func GenerateULIDFromTime ¶ added in v1.22.0
GenerateULIDFromTime :nodoc:
func GenerateUUID ¶ added in v1.34.0
func GenerateUUID() string
GenerateUUID generate random UUID v4
func GetCronNextAt ¶ added in v1.27.0
GetCronNextAt supports
- Standard crontab specs, e.g. "* * * * ?"
- Descriptors, e.g. "@midnight", "@every 1h30m"
if cron parsing error then return current time
func GetDifferenceDaysForHumans ¶ added in v1.13.0
GetDifferenceDaysForHumans return difference days for humans in indonesian language
func GraphQLIDPointerToInt32 ¶
GraphQLIDPointerToInt32 :nodoc:
func GraphQLIDPointerToInt64 ¶
GraphQLIDPointerToInt64 :nodoc:
func GraphQLIDPointerToString ¶
GraphQLIDPointerToString :nodoc:
func Int64MillisToPointerTime ¶ added in v1.11.0
Int64MillisToPointerTime convert millis to pointer time in UTC
func Int64MillisToTime ¶ added in v1.11.0
Int64MillisToTime convert millis to time in UTC
func Int64PointerToInt64 ¶ added in v1.23.0
Int64PointerToInt64 :nodoc:
func Int64WithLimit ¶
Int64WithLimit -> Check req value bigger or not from limit.
func Int64WithMinAndMaxLimit ¶ added in v1.20.0
Int64WithMinAndMaxLimit check input value. if bigger than max, then return max. if smaller than min, then return min. else return input.
func InterfaceBytesToInt64 ¶
func InterfaceBytesToInt64(i interface{}) int64
InterfaceBytesToInt64 will transform cached value that get from the redis to Int64
func InterfaceBytesToType ¶ added in v1.21.0
func InterfaceBytesToType[T any](i interface{}) (out T)
InterfaceBytesToType will transform cached value that get from the redis to any types
func IsSameSliceIgnoreOrder ¶
IsSameSliceIgnoreOrder to compare slice without order
func IsURLReachable ¶ added in v1.36.0
IsURLReachable check is the url reachable
func IsUniqueSliceItem ¶ added in v1.37.0
func IsUniqueSliceItem[T comparable](data []T) bool
IsUniqueSliceItem :nodoc:
func LowerMapStringKey ¶ added in v1.3.0
LowerMapStringKey :nodoc:
func MapValuesToOrderedSlice ¶ added in v1.31.0
func MapValuesToOrderedSlice[K comparable, V any](src map[K]V, keysOrder []K) (orderedMapValues []V)
MapValuesToOrderedSlice convert map values to ordered slice. If the map didn't contain one or more key in the keysOrder slice, then it will be filled with zero value.
func MyCaller ¶ added in v1.2.0
MyCaller will return the method caller. skip value defines how many steps to be skipped. skip=0 will always return the MyCaller skip=1 returns the caller of the MyCaller and so on...
func PaginateSlice ¶ added in v1.29.0
func PaginateSlice[T comparable](data []T, page, size int64) []T
PaginateSlice :nodoc:
func ParseDurationWithDefault ¶ added in v1.23.0
ParseDurationWithDefault self explained
func SlicePointerInt32PointerToSliceInt64 ¶
SlicePointerInt32PointerToSliceInt64 :nodoc:
func StandardizeSpaces ¶
StandardizeSpaces -> JoinURL long query to one line query
func StringMillisToPointerTime ¶ added in v1.10.0
StringMillisToPointerTime convert millis to pointer time in UTC
func StringMillisToTime ¶ added in v1.10.0
StringMillisToTime convert millis to time in UTC
func StringPointerToFloat64 ¶
StringPointerToFloat64 :nodoc:
func StringPointerToString ¶
StringPointerToString :nodoc:
func StringToInt64WithDefault ¶
StringToInt64WithDefault :nodoc:
func Ternary ¶
func Ternary(condition bool, a, b interface{}) interface{}
Ternary if condition is true, return a else b
func TimeFromObjectIDHex ¶ added in v1.30.0
TimeFromObjectIDHex extracts time data from bson's objectID
func TrimSpacePointerString ¶ added in v1.33.0
func TrimSpacePointerString(s *string)
TrimSpacePointerString :nodoc:
func TruncateString ¶ added in v1.7.0
TruncateString by length, and add ellipsis at the end
func UnescapeString ¶
UnescapeString UTF-8 string e.g. convert "\u0e27\u0e23\u0e0d\u0e32" to "วรญา"
func Unique ¶ added in v1.21.0
func Unique[T comparable](elements []T) (result []T)
Unique returns unique value in as slice
func ValueOfPointer ¶ added in v1.33.0
func ValueOfPointer[T comparable](i *T) T
ValueOfPointer return value of pointer T
func ValueOrDefault ¶ added in v1.26.0
func ValueOrDefault[T comparable](value, defaultValue T) T
ValueOrDefault use the given value or use default value if the value = empty value
Types ¶
type Hook ¶ added in v1.15.0
type Hook struct {
// contains filtered or unexported fields
}
Hook "the hook"
func (*Hook) SetEnvironment ¶ added in v1.15.0
SetEnvironment implements SetEnvironment
func (*Hook) SetFlushTimeout ¶ added in v1.15.0
SetFlushTimeout implements SetFlushTimeout
func (*Hook) SetRelease ¶ added in v1.15.0
SetRelease implements SetRelease
type RetryStopper ¶
type RetryStopper struct {
// contains filtered or unexported fields
}
RetryStopper :nodoc:
func NewRetryStopper ¶ added in v1.3.1
func NewRetryStopper(err error) RetryStopper
NewRetryStopper :nodoc: