ihelper

package module
v0.0.0-...-ce3b957 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: MIT Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TimeLocationUTC     *time.Location = time.UTC
	TimeLocationJakarta *time.Location = LoadTimeLocation("Asia/Jakarta")
)

Functions

func ChiURLParamToFloat32

func ChiURLParamToFloat32(r *http.Request, key string, def float32) (res float32)

func ChiURLParamToFloat64

func ChiURLParamToFloat64(r *http.Request, key string, def float64) (res float64)

func ChiURLParamToInt

func ChiURLParamToInt(r *http.Request, key string, def int) (res int)

func ChiURLParamToInt64

func ChiURLParamToInt64(r *http.Request, key string, def int64) (res int64)

func ChiURLParamToString

func ChiURLParamToString(r *http.Request, key string) string

func GenerateBookingCode

func GenerateBookingCode(orderAt time.Time, email, username, phone string, charlen int) (res string)

func GenerateID

func GenerateID(prefix ...string) (res string)

func GenerateObjectID

func GenerateObjectID(prefix ...string) (res string)

func GenerateProductCode

func GenerateProductCode(names ...string) (res string)

func GenerateProductCodeWithCode

func GenerateProductCodeWithCode(code bool, names ...string) (res string)

func GenerateRandom

func GenerateRandom(min, max int) int

func GenerateRandomString

func GenerateRandomString(letters string, charlen int) (res string)

func GenerateSessionID

func GenerateSessionID(email, username, phone string) (res string)

func GenerateTranscationID

func GenerateTranscationID(generateAt time.Time, email, username, phone string, charlen int) (res string)

func GenerateULID

func GenerateULID(prefix ...string) (res string)

func GenerateUUID

func GenerateUUID(prefix ...string) (res string)

func GetAlphanumeric

func GetAlphanumeric(s string) (res string)

func IsArrayStringExist

func IsArrayStringExist(ars []string, s string) (b bool)

func IsEmailValid

func IsEmailValid(email string) bool

func IsPhoneCodeValid

func IsPhoneCodeValid(phoneCode string) bool

func IsPhoneValid

func IsPhoneValid(phone string) bool

func LoadTimeLocation

func LoadTimeLocation(loc string) (l *time.Location)

func MaxFloat64

func MaxFloat64(s ...float64) (r float64)

func MaxInt

func MaxInt(s ...int) (r int)

func MaxInt64

func MaxInt64(s ...int64) (r int64)

func MinFloat64

func MinFloat64(s ...float64) (r float64)

func MinInt

func MinInt(s ...int) (r int)

func MinInt64

func MinInt64(s ...int64) (r int64)

func MustLoadTimeWithLocation

func MustLoadTimeWithLocation(t time.Time, loc *time.Location) time.Time

func MustParseTime

func MustParseTime(from, layout string) (res time.Time)

func MustParseTimeWithLocation

func MustParseTimeWithLocation(from, layout string, loc *time.Location) time.Time

func QueryString

func QueryString(r *http.Request, key string) string

QueryStringToString definition

func QueryStringToBool

func QueryStringToBool(r *http.Request, key string) bool

QueryStringToFloat64 definition

func QueryStringToFloat64

func QueryStringToFloat64(r *http.Request, key string, def float64) float64

QueryStringToFloat64 definition

func QueryStringToFloat64Ptr

func QueryStringToFloat64Ptr(r *http.Request, key string) *float64

QueryStringToFloat64 definition

func QueryStringToInt

func QueryStringToInt(r *http.Request, key string, def int) int

QueryStringToInt definition

func QueryStringToInt64

func QueryStringToInt64(r *http.Request, key string, def int64) int64

QueryStringToInt definition

func QueryStringToInts

func QueryStringToInts(r *http.Request, key string, def int) (res []int)

func QueryStringToPointerBool

func QueryStringToPointerBool(r *http.Request, key string) *bool

QueryStringToFloat64 definition

func QueryStringToTime

func QueryStringToTime(r *http.Request, key string) time.Time

func QueryStringToTimeWithFromat

func QueryStringToTimeWithFromat(r *http.Request, key, format string) (t time.Time)

func QueryStrings

func QueryStrings(r *http.Request, key string) []string

func RegisterDeleteEndpoint

func RegisterDeleteEndpoint(logger *logrus.Logger, r chi.Router, handler http.HandlerFunc, pattern ...string)

func RegisterGetEndpoint

func RegisterGetEndpoint(logger *logrus.Logger, r chi.Router, handler http.HandlerFunc, pattern ...string)

func RegisterPatchEndpoint

func RegisterPatchEndpoint(logger *logrus.Logger, r chi.Router, handler http.HandlerFunc, pattern ...string)

func RegisterPostEndpoint

func RegisterPostEndpoint(logger *logrus.Logger, r chi.Router, handler http.HandlerFunc, pattern ...string)

func RegisterPutEndpoint

func RegisterPutEndpoint(logger *logrus.Logger, r chi.Router, handler http.HandlerFunc, pattern ...string)

func SearchInArrayString

func SearchInArrayString(ars []string, s string) (pos int)

func StringOr

func StringOr(ss ...string) string

func ToCursorString

func ToCursorString(encryption appencryption.Encryptor, mapCursor map[string]bson.M) (lastCursor string, err error)

func ToFloat32

func ToFloat32(src string, def float32) (res float32)

func ToFloat64

func ToFloat64(src string, def float64) (res float64)

func ToInt

func ToInt(from string, deflt int) int

func ToInt64

func ToInt64(from string, def int64) (res int64)

func ToIntFromBool

func ToIntFromBool(b bool, t, f int) int

func ToIntWithMax

func ToIntWithMax(from string, deflt, max int) int

func ToIntWithMin

func ToIntWithMin(from string, deflt, min int) int

func ToIntWithMinMax

func ToIntWithMinMax(from string, deflt, min, max int) int

func ToMapCursor

func ToMapCursor(mapCursor map[string]bson.M) (mongoFilter bson.M)

func ToMongoSort

func ToMongoSort(sorts []string) (mongoSort bson.D)

func ToTimeInt

func ToTimeInt(t time.Time) int64

func ToTimeIntWithLocation

func ToTimeIntWithLocation(t time.Time, loc *time.Location) int64

func ToTimeString

func ToTimeString(t time.Time) string

func ToTimeStringWithLocation

func ToTimeStringWithLocation(t time.Time, loc *time.Location) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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