Documentation ¶
Index ¶
- Constants
- func CurrentLocalTime() time.Time
- func CurrentUTCTime() time.Time
- func CurrentUTCTimeRef() *time.Time
- func CurrentUnixTimestamp() int64
- func GenerateCardNumberFromBin(bin string, cardNumberLen int) string
- func GetBasic(ctx context.Context, key string) (value interface{})
- func GetExtra(ctx context.Context, key string) (value interface{})
- func GetStatsD(ctx context.Context) (statsD *statsd.Client)
- func GetString(ctx context.Context, key ContextKey) (value string)
- func SetBasic(parent context.Context, key string, value interface{}) context.Context
- func SetBasics(parent context.Context, basics Basics) context.Context
- func SetExtra(parent context.Context, key string, value interface{}) context.Context
- func SetExtras(parent context.Context, extras Extras) context.Context
- func SetStatsD(parent context.Context, statsD *statsd.Client) context.Context
- func TimeChanged(new *time.Time, base *time.Time) (bool, *time.Time)
- func ValidateCardNumber(number string) bool
- type Basics
- type ContextKey
- type DMutex
- type Date
- type DistributedLocker
- type Extras
- type UnLocker
Constants ¶
const ( ClientCodeParam = "clientCode" MaxRequestIDLength = 64 BINLength = 6 )
common constants
const ( DateFormat = "02 Jan 2006" DayOfWeekFormat = "Mon" DateTimeFormat = "02 Jan 2006, 03:04 PM MST" YearFormat = "2006" )
date time string formats
Variables ¶
This section is empty.
Functions ¶
func CurrentLocalTime ¶
CurrentLocalTime returns current date time in local timezone
func CurrentUTCTime ¶
CurrentUTCTime returns current date time in UTC
func CurrentUTCTimeRef ¶
CurrentUTCTimeRef returns current date time reference in UTC
func CurrentUnixTimestamp ¶
func CurrentUnixTimestamp() int64
CurrentUnixTimestamp returns current Unix timestamp (seconds)
func GenerateCardNumberFromBin ¶ added in v0.1.14
GenerateCardNumberFromBin will generate credit card number based on bin number and the card number length
func GetString ¶
func GetString(ctx context.Context, key ContextKey) (value string)
GetString gets string from a context by ContextKey
func SetBasic ¶ added in v0.1.4
SetBasic returns a copy of parent context with basic key value added into it
func SetBasics ¶ added in v0.1.3
SetBasics returns a copy of parent context with basics added into it
func SetExtra ¶ added in v0.1.6
SetExtra returns a copy of parent context with Extra key value added into it
func TimeChanged ¶
TimeChanged check if new time changed from the base, return the changed flag and time value
func ValidateCardNumber ¶
ValidateCardNumber will check the credit card's number against the Luhn algorithm
Types ¶
type Basics ¶ added in v0.1.3
type Basics map[string]interface{}
Basics are basics information to be added into context
type DMutex ¶
type DMutex struct {
// contains filtered or unexported fields
}
DMutex a simple distributed mutex for lock with keys
type Date ¶
Date : custom date in format yyyy-MM-dd
func (Date) MarshalJSON ¶
MarshalJSON marshall Date into JSON
func (*Date) UnmarshalJSON ¶
UnmarshalJSON Parses the json string in the Date
type DistributedLocker ¶
DistributedLocker a distributed lock type