gutils

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2022 License: Apache-2.0 Imports: 19 Imported by: 2

Documentation

Index

Constants

View Source
const (
	XForwardedFor = "X-Forwarded-For" // 获取真实ip
	XRealIP       = "X-Real-IP"       // 获取真实ip
)

Variables

View Source
var (
	//CJson 全局json对象
	CJson = jsonIter.ConfigCompatibleWithStandardLibrary
)

Functions

func Base64Decode

func Base64Decode(code string) string

func Base64Encode

func Base64Encode(s string) string

func Base64URLDecode

func Base64URLDecode(data string) string

Base64URLDecode 因为Base64转码后可能包含有+,/,=这些不安全的URL字符串,所以要进行换字符 '+' -> '-' '/' -> '_' '=' -> ” 字符串长度不足4倍的位补"="

func Base64UrlSafeEncode

func Base64UrlSafeEncode(data string) string

func CreateOrder

func CreateOrder() int64

CreateOrder 生成订单号

func Exists

func Exists(filePath string) bool

Exists 判断文件或目录是否存在

func GenValidateCode

func GenValidateCode(width int) string

GenValidateCode 生成6位随机验证码

func GenerateTraceId

func GenerateTraceId() string

GenerateTraceId 获取链路TraceId

func GetAddressByIP

func GetAddressByIP(ipA string) string

GetAddressByIP 获取省市区通过ip

func GetLocalIPs

func GetLocalIPs() (ips []string)

func GetLock

func GetLock(redisConn *redis.Client, lockName string, acquireTimeout, lockTimeOut time.Duration) (string, error)

GetLock 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 GetRandomString

func GetRandomString(l int) string

GetRandomString 获取随机字符串

func GetRandomString6

func GetRandomString6(n uint64) []byte

GetRandomString6 获取6位随机字符串

func GetString

func GetString(d interface{}) string

GetString 只能是map和slice

func InSliceString

func InSliceString(k string, s []string) bool

InSliceString string是否在[]string里面

func IsNil

func IsNil(obj interface{}) bool

func Md5

func Md5(s string) string

Md5 md5

func ReleaseLock

func ReleaseLock(redisConn *redis.Client, lockName, code string) bool

ReleaseLock var count = 0 // test assist

func RemoteIp

func RemoteIp(r *http.Request) string

RemoteIp 返回远程客户端的 IP,如 192.168.1.1

Types

This section is empty.

Jump to

Keyboard shortcuts

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