Documentation ¶
Index ¶
- Constants
- Variables
- func Err(code uint32) (err error)
- func GenValidateCode(width int) string
- func GetAddressByIP(ipA string) string
- func GetLock(redisConn *redis.Client, lockName string, ...) (string, error)
- func GetRandomString(l int) string
- func GetRandomString6(n uint64) []byte
- func Md5(key ...string) string
- func ReleaseLock(redisConn *redis.Client, lockName, code string) bool
- func RemoteIp(req *http.Request) string
- type HeaderParam
- type Resp
- type RspError
- type Time
- func (t Time) Equal(other Time) bool
- func (t Time) ExactEqual(other Time) bool
- func (t Time) IsZero() bool
- func (t Time) MarshalJSON() ([]byte, error)
- func (t Time) MarshalText() ([]byte, error)
- func (t Time) Ptr() *time.Time
- func (t *Time) SetValid(v time.Time)
- func (t *Time) UnmarshalJSON(data []byte) error
- func (t *Time) UnmarshalText(text []byte) error
- func (t Time) Value() (driver.Value, error)
- func (t Time) ValueOrZero() time.Time
Constants ¶
const ( XForwardedFor = "X-Forwarded-For" // 获取真实ip XRealIP = "X-Real-IP" // 获取真实ip )
const LogKey = "request-id"
Variables ¶
var Errno = map[uint32]string{
400: "系统错误",
}
var (
SystemErr = Err(400)
)
Functions ¶
func GetLock ¶
func GetLock(redisConn *redis.Client, lockName string, acquireTimeout, lockTimeOut time.Duration) (string, error)
acquireTimeout Get the lock timeout period, If no lock is obtained within this period, err will be returned here lockTimeOut Lock timeout to prevent deadlock, lock automatically unlocked by this time
func ReleaseLock ¶
var count = 0 // test assist
Types ¶
type HeaderParam ¶
type Time ¶
Time is a nullable time.Time. It supports SQL and JSON serialization. It will marshal to null if null.
func TimeFromPtr ¶
TimeFromPtr creates a new Time that will be null if t is nil.
func (Time) Equal ¶
Equal returns true if both Time objects encode the same time or are both null. Two times can be equal even if they are in different locations. For example, 6:00 +0200 CEST and 4:00 UTC are Equal.
func (Time) ExactEqual ¶
ExactEqual returns true if both Time objects are equal or both null. ExactEqual returns false for times that are in different locations or have a different monotonic clock reading.
func (Time) IsZero ¶
IsZero returns true for invalid Times, hopefully for future omitempty support. A non-null Time with a zero value will not be considered zero.
func (Time) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It will encode null if this time is null.
func (Time) MarshalText ¶
MarshalText implements encoding.TextMarshaler. It returns an empty string if invalid, otherwise time.Time's MarshalText.
func (Time) Ptr ¶
Ptr returns a pointer to this Time's value, or a nil pointer if this Time is null.
func (*Time) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It supports string and null input.
func (*Time) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler. It has backwards compatibility with v3 in that the string "null" is considered equivalent to an empty string and unMarshaling will succeed. This may be removed in a future version.
func (Time) ValueOrZero ¶
ValueOrZero returns the inner value if valid, otherwise zero.