utils

package
v0.0.0-...-0b51059 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DateLayout     = "2006-01-02"
	DateTimeLayout = "2006-01-02 15:04:05"

	DateLayoutSlash     = "2006/01/02"
	DateTimeLayoutSlash = "2006/01/02 15:04:05"

	DateShortLayout      = "06-01-02"
	DateShortLayoutSlash = "06/01/02"

	MonthDateLayout      = "01-02"
	MonthDateLayoutSlash = "01/02"

	TimeLayout       = "15:04:05"
	TimeMinuteLayout = "15:04"
)
View Source
const NormalLetters string = "abcdefghjkmnopqrstuvwxyzABCDEFGHJKMNOPQRSTUVWXYZ123456789"
View Source
const NumberLetters string = "0123456789"

Variables

This section is empty.

Functions

func CellphoneCheckRule

func CellphoneCheckRule() string

CellphoneCheckRule 手机号验证规则

func EmailCheckRule

func EmailCheckRule() string

EmailCheckRule 邮箱验证规则

func FakeIdCartNumber

func FakeIdCartNumber() string

FakeIdCartNumber 随机生成可通过校验的虚拟身份证号

func GeneratePassword

func GeneratePassword(password string) (string, string)

GeneratePassword 生成密码串和盐

func Int64InArrayIndex

func Int64InArrayIndex(x int64, array []int64) int

func IntInArrayIndex

func IntInArrayIndex(x int, array []int) int

func IsCellphone

func IsCellphone(phone string) bool

IsCellphone 校验手机号码规则

func IsEmail

func IsEmail(email string) bool

IsEmail 校验邮箱规则

func IsIdCardNumber

func IsIdCardNumber(card string) bool

IsIdCardNumber 校验身份证号码规则,支持15位、18位及末位X,且会验证身份证号的合法性

func Md5

func Md5(str string) string

Md5 获取字符串的md5值

func MkdirIfNotExist

func MkdirIfNotExist(dir string) error

func RandomNumberStr

func RandomNumberStr(i ...int) string

RandomNumberStr 生成随机数字字符串,默认长度6

func RandomStr

func RandomStr(i ...int) string

RandomStr 生成随机字符串,默认长度8

func StrInArrayIndex

func StrInArrayIndex(str string, array []string) int

func TotalPage

func TotalPage(size, total int) int

计算总页数

func UUID

func UUID() string

UUID 生成不带中划线UUID

func VerifyPassword

func VerifyPassword(password, hashPwd, salt string) bool

VerifyPassword 校验密码

Types

type Captcha

type Captcha struct {
	Width  int
	Height int
	Length int
	// contains filtered or unexported fields
}

func NewCaptcha

func NewCaptcha(width, height, length int) *Captcha

func (*Captcha) GenerateLettersImage

func (c *Captcha) GenerateLettersImage() (code string, b64s string, err error)

GenerateLettersImage 生成数字与字母混合的验证码和图片

func (*Captcha) GenerateMathImage

func (c *Captcha) GenerateMathImage() (code string, b64 string, err error)

GenerateMathImage 生成算术验证码和图片

func (*Captcha) GenerateNumberImage

func (c *Captcha) GenerateNumberImage() (code string, b64s string, err error)

GenerateNumberImage 生成全数字验证码和图片

func (*Captcha) SetBgColor

func (c *Captcha) SetBgColor(rgba color.RGBA)

func (*Captcha) SetFonts

func (c *Captcha) SetFonts(fonts []string)

func (*Captcha) SetStore

func (c *Captcha) SetStore(store base64Captcha.Store)

func (*Captcha) Verify

func (c *Captcha) Verify(id, answer string) (match bool)

Verify 校验应答的验证码,校验完成无论是否正确都会清理缓存 @param id string "生成验证码时的ID" @param answer string "应答码"

type CaptchaRedisStore

type CaptchaRedisStore struct {
	// contains filtered or unexported fields
}

func NewCaptchaRedisStore

func NewCaptchaRedisStore(client *redis.Client, keyPrefix string) *CaptchaRedisStore

func (*CaptchaRedisStore) Get

func (c *CaptchaRedisStore) Get(id string, clear bool) string

func (*CaptchaRedisStore) Set

func (c *CaptchaRedisStore) Set(id string, value string) error

func (*CaptchaRedisStore) SetExpiration

func (c *CaptchaRedisStore) SetExpiration(expiration time.Duration)

func (*CaptchaRedisStore) Verify

func (c *CaptchaRedisStore) Verify(id, answer string, clear bool) (match bool)

type IdCartInfo

type IdCartInfo idvalidator.IdInfo

func GetIdCartInfo

func GetIdCartInfo(card string) (*IdCartInfo, error)

GetIdCartInfo 严格模式获取身份证号信息 []interface {}[

github.com/guanguans/id-validator.IdInfo{          // 身份证号信息
    AddressCode: int(500154)                           // 地址码
    Abandoned:   int(0)                                // 地址码是否废弃:1为废弃的,0为正在使用的
    Address:     string("重庆市市辖区开州区")             // 地址
    AddressTree: []string[                             // 省市区三级列表
        string("重庆市")                                    // 省
        string("市辖区")                                    // 市
        string("开州区")                                    // 区
    ]
    Birthday:      <1993-01-13 00:00:00 +0800 CST>     // 出生日期
    Constellation: string("摩羯座")                     // 星座
    ChineseZodiac: string("酉鸡")                       // 生肖
    Sex:           int(0)                              // 性别:1为男性,0为女性
    Length:        int(18)                             // 号码长度
    CheckBit:      string("6")                         // 校验码
}
<nil>                                              // 错误信息

]

type LocalTime

type LocalTime time.Time

func (*LocalTime) MarshalJSON

func (t *LocalTime) MarshalJSON() ([]byte, error)

func (*LocalTime) Scan

func (t *LocalTime) Scan(v interface{}) error

func (LocalTime) Value

func (t LocalTime) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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