tools

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2020 License: Apache-2.0 Imports: 21 Imported by: 2

Documentation

Index

Constants

View Source
const GoTime = "2006-01-02 15:04:05"

Variables

View Source
var (
	Tools = New()
)

Functions

This section is empty.

Types

type Tool

type Tool struct {
}

func New

func New() (t *Tool)

*

  • 返回单例实例
  • @method New

func (*Tool) AmountToCN

func (t *Tool) AmountToCN(pMoney float64, pRound bool) string

金额转大写

func (*Tool) BcryptHashCompare

func (t *Tool) BcryptHashCompare(current string, req string) bool

BcryptHashCompare 对比bctypt的哈希值

func (*Tool) BcryptHashGenerate

func (t *Tool) BcryptHashGenerate(s string) string

BcryptHashGenerate 生成bctypt的哈希值

func (*Tool) CheckNickName

func (t *Tool) CheckNickName(nikename string) (err error)

func (*Tool) CheckPasswordLevel

func (t *Tool) CheckPasswordLevel(ps string) error

func (*Tool) CheckUserName

func (t *Tool) CheckUserName(uname string) (err error)

func (*Tool) EncodeMD5

func (t *Tool) EncodeMD5(value string) string

EncodeMD5 MD5哈希值

func (*Tool) FloatToStr

func (t *Tool) FloatToStr(f float64) string

*

  • float转string

func (*Tool) GBK2UTF8

func (t *Tool) GBK2UTF8(s []byte) ([]byte, error)

*

  • GBK2UTF8

func (*Tool) GetRandomInt

func (t *Tool) GetRandomInt(n int) string

生成随机验证码

func (*Tool) GetRandomString

func (t *Tool) GetRandomString(n int) string

*

  • 生成随机字符串

func (*Tool) HideStar

func (t *Tool) HideStar(str string) (result string)

func (*Tool) IntToStr

func (t *Tool) IntToStr(i int) string

*

  • int转string

func (*Tool) MustUUID

func (t *Tool) MustUUID() string

MustUUID 创建UUID,如果发生错误则抛出panic

func (*Tool) PtrIsNil

func (t *Tool) PtrIsNil(ptr interface{}) bool

*

  • PtrIsNil

func (*Tool) RemoteIp

func (t *Tool) RemoteIp(req *http.Request) string

func (*Tool) RemoveRepeated

func (t *Tool) RemoveRepeated(obj interface{}) (err error)

*

  • RemoveRepeated

func (*Tool) StrToInt

func (t *Tool) StrToInt(str string, def int) (int, error)

*

  • string转int

func (*Tool) StrToInt64

func (t *Tool) StrToInt64(str string, def int64) (int64, error)

*

  • string转int64

func (*Tool) StrToUint

func (t *Tool) StrToUint(str string, def uint) (uint, error)

*

  • string转uint

func (*Tool) StringFormatTime

func (t *Tool) StringFormatTime(timeLayout string) int64

func (*Tool) StructToMap

func (t *Tool) StructToMap(obj interface{}) (result map[string]interface{}, err error)

*

  • 结构体转换成map对象,常用于解决gorm使用结构体update时忽略零值的问题

func (*Tool) StructToStr

func (t *Tool) StructToStr(data interface{}) (string, error)

*

  • struct转成json

func (*Tool) StructToStruct

func (t *Tool) StructToStruct(source, input interface{}) (err error)

*

  • 结构体赋值到另一个结构体

func (*Tool) SubString

func (t *Tool) SubString(str string, start, length int) string

*

  • 字符串截取

func (*Tool) Substr2

func (t *Tool) Substr2(str string, start int, end int) string

func (*Tool) TimeFormat

func (t *Tool) TimeFormat(time time.Time, format string) string

*

  • TimeFormat

func (*Tool) UTF82GB2312

func (t *Tool) UTF82GB2312(s []byte) ([]byte, error)

*

  • UTF82GB2312

func (*Tool) UTF82GBK

func (t *Tool) UTF82GBK(s []byte) ([]byte, error)

*

  • UTF82GBK

func (*Tool) VerifyEmailFormat

func (t *Tool) VerifyEmailFormat(email string) bool

email verify

func (*Tool) VerifyMobileFormat

func (t *Tool) VerifyMobileFormat(mobileNum string) bool

mobile verify

Jump to

Keyboard shortcuts

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