Documentation
¶
Index ¶
- Constants
- func ContextWithRequestId(ctx context.Context, requestId string) context.Context
- func EmptyStringWhenNil(str *string) string
- func EqualPointerValue[T comparable](a *T, b *T) bool
- func GetLogger(c context.Context) *logrus.Entry
- func GetRequestIdFromMessage(message []byte) string
- func InSlice[T comparable](list []T, str T) bool
- func IsDuplicateError(e error) bool
- func IsEmptyTrimString(str *string) bool
- func IsNotFoundError(e error) bool
- func IsParameterError(e error) bool
- func IsRetyableError(e error) bool
- func IsStringContainsPattern(str string, pattern string) bool
- func IsStringInArray(str string, arr []string) bool
- func IsStringPhoneNumber(contact string) bool
- func IsUnprocessableEntityError(e error) bool
- func JsonParse(jsonBytes []byte, receiver interface{}) error
- func JsonString(obj interface{}) (*string, error)
- func MaskEmail(str string) string
- func MaskPhone(str string) string
- func MergeSlices[T any](vals ...[]T) (merged []T)
- func MustJsonString(obj interface{}) string
- func NormalizeEmail(email string) string
- func NormalizePhoneNumber(phone string) string
- func NormalizeSimple(str *string) string
- func NormalizeSimpleKeepSpace(str *string) string
- func Pointer[T any](data T) *T
- func RemoveNonAlphaNumChar(str string) string
- func RemoveNonAlphaNumSpaceChar(str string) string
- func StrLimit(str *string, limit int) *string
- func StrReplace(str string, before string, after string) string
- func StrToLower(str string) string
- func StringToTime(timeStr *string) *time.Time
- func TimeToMilisecond(t *time.Time) int64
- func ToInt64[T NumberType](data *T) (result *int64)
- func ToString[T NumberType](data *T) *string
- func TrimAndLowerString(str string) string
- func UuidV4Fn() func() string
- func Val[T any](pointer *T) T
- func ValTimeUnix(val *time.Time) int64
- type Error
- type NumberType
Constants ¶
View Source
const ( ErrorBadRequest int = 400 ErrorNotFound int = 404 ErrorDuplicate int = 409 ErrorUnprocessableEntity int = 422 ErrorInternalService int = 500 )
View Source
const ContextKeyRequestId key = "requestId"
Variables ¶
This section is empty.
Functions ¶
func ContextWithRequestId ¶
func EmptyStringWhenNil ¶
EmptyStringWhenNil will return empty string when arg is nil, or arg when not nil
func EqualPointerValue ¶
func EqualPointerValue[T comparable](a *T, b *T) bool
func GetRequestIdFromMessage ¶
func InSlice ¶
func InSlice[T comparable](list []T, str T) bool
func IsDuplicateError ¶
func IsEmptyTrimString ¶
func IsNotFoundError ¶
func IsParameterError ¶
func IsRetyableError ¶
func IsStringContainsPattern ¶
IsStringContainsPattern will check based on regex
func IsStringInArray ¶
func IsStringPhoneNumber ¶
func JsonString ¶
func MergeSlices ¶
func MergeSlices[T any](vals ...[]T) (merged []T)
func MustJsonString ¶
func MustJsonString(obj interface{}) string
func NormalizeEmail ¶
func NormalizePhoneNumber ¶
func NormalizeSimple ¶
NormalizeSimple will remove all non alphanumeric chars, lower, and trim given string will return empty string if str is nil
func RemoveNonAlphaNumChar ¶
RemoveNonAlphaNumChar will return string with removed non alphanumeric chars or empty string if nil was given
func StrToLower ¶
StrToLower returns `str` with all Unicode letters mapped to their lower case.
func StringToTime ¶
func TimeToMilisecond ¶
func ToInt64 ¶
func ToInt64[T NumberType](data *T) (result *int64)
func ToString ¶
func ToString[T NumberType](data *T) *string
func TrimAndLowerString ¶
TrimAndLowerString will return whitespace-trimmed and lowered-case version of the given str
func ValTimeUnix ¶
Types ¶
type Error ¶
func NewDuplicateError ¶
func NewDuplicateError() Error
func NewLimitReachedError ¶
func NewLimitReachedError() Error
func NewNotFoundError ¶
func NewNotFoundError() Error
func NewParameterError ¶
func NewUnauthorizedError ¶
func NewUnauthorizedError() Error
Click to show internal directories.
Click to hide internal directories.