util

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2020 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const IntMax = int(^uint(0) >> 1)

IntMax 最大int值

Variables

This section is empty.

Functions

func Base64

func Base64(s string) string

Base64 编码

func CheckIDCard added in v0.0.7

func CheckIDCard(idCard string) bool

CheckIDCard 校验身份证

func CheckMobile

func CheckMobile(mobile string, countryCode int) bool

CheckMobile 校验手机号(只校验大陆手机号)

func CheckPassword

func CheckPassword(password string) bool

CheckPassword 校验密码

func ClientIP added in v0.0.4

func ClientIP(r *http.Request, c *websocket.Conn) string

ClientIP 获取客户端IP

func Exists added in v0.2.6

func Exists(path string) bool

Exists 判断路径文件夹是否存在

func GinContext

func GinContext(ctx context.Context) (*gin.Context, error)

GinContext 获取gin上下文

func IsDir added in v0.2.6

func IsDir(path string) bool

IsDir 判断路径是否是文件夹

func IsFile added in v0.2.6

func IsFile(path string) bool

IsFile 判断是否是文件

func ItoB

func ItoB(i interface{}) bool

ItoB Any转布尔值

func ItoF64

func ItoF64(i interface{}, val ...float64) float64

ItoF64 Any转浮点数

func ItoI

func ItoI(i interface{}, val ...int) int

ItoI Any转整数

func ItoI64

func ItoI64(i interface{}, val ...int64) int64

ItoI64 Any转整数

func ItoS

func ItoS(i interface{}, val ...string) string

ItoS Any转字符串

func ItoSQL

func ItoSQL(i interface{}) string

ItoSQL Any转SQL字符串,字符带”,数字不带”

func ItoSQLLike

func ItoSQLLike(i interface{}) string

ItoSQLLike Any转Like字符串'%...%'

func MilliSecondTimestamp

func MilliSecondTimestamp() int64

MilliSecondTimestamp 毫秒时间戳

func MixMobile

func MixMobile(mobile string) string

MixMobile 混淆手机号

func MtoB

func MtoB(src map[string]interface{}, key string) bool

MtoB 获取map布尔值

func MtoF64

func MtoF64(src map[string]interface{}, key string, val ...float64) float64

MtoF64 获取map浮点数值

func MtoI

func MtoI(src map[string]interface{}, key string, val ...int) int

MtoI 获取map整数值

func MtoI64

func MtoI64(src map[string]interface{}, key string, val ...int64) int64

MtoI64 获取map整数值64位

func MtoS

func MtoS(src map[string]interface{}, key string, val ...string) string

MtoS 获取map字符串值

func NewBytesMD5 added in v0.2.2

func NewBytesMD5(data []byte) string

NewBytesMD5 字节流MD5

func NewMD5

func NewMD5(s string) string

NewMD5 MD5 32位 小写

func NewMD516 added in v0.2.6

func NewMD516(s string) string

NewMD516 MD5 16位 小写

func NewObjectID added in v0.2.0

func NewObjectID() string

NewObjectID 生成mongo字符串ID

func NewPassword

func NewPassword(pwd string, code string) string

NewPassword 生成密码

func NewSequenceID

func NewSequenceID() int64

NewSequenceID 创建数字唯一编号

func NewSnowID added in v0.2.0

func NewSnowID() snowflake.ID

NewSnowID 新建一个雪花ID

func NewTenantID added in v0.2.0

func NewTenantID() string

NewTenantID 新建租户编号

func NewUUID

func NewUUID() string

NewUUID 创建UUID唯一编号

func ParseTime

func ParseTime(s string, layout ...string) (time.Time, error)

ParseTime 字符串转时间,默认格式 2006-01-02 15:04:05

func RandomInt64

func RandomInt64(b ...int) int64

RandomInt64 生成指定位数的随机数字

func RandomInt64MinMax

func RandomInt64MinMax(min, max int64) int64

RandomInt64MinMax 生成指定范围内的随机数字

func SnowIDInit added in v0.2.0

func SnowIDInit(n int) error

SnowIDInit 初始化雪花ID,n代表节点数,0~1023,不可以重复

func TimeFormat

func TimeFormat(t time.Time, layout ...string) string

TimeFormat 将时间格式化为字符串

func VerifyPassword

func VerifyPassword(n string, o string, code string) bool

VerifyPassword 验证密码,一致返回true,否则返回false

Types

This section is empty.

Jump to

Keyboard shortcuts

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