utils_go

package module
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2022 License: MIT Imports: 20 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Day                 = time.Hour * 24
	DaySecond           = Day / time.Second
	Month               = Day * 30
	MonthSecond         = DaySecond * 30
	Year                = Month * 365
	YearSecond          = MonthSecond * 365
	RegexpPatternEmail  = "[\\w!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\\w](?:[\\w-]*[\\w])?\\.)+[\\w](?:[\\w-]*[\\w])?"
	RegexpPatternMobile = "^((13[0-9])|(14[5,7,9])|(15[^4])|(18[0-9])|(17[0,1,3,5,6,7,8])|(19)[0-9])\\d{8}$"
	TIMESTAMPZONE       = "2006-01-02 15:04:05.999999999 -0700"
	YYYYMMDDHHMMSS      = "2006-01-02 15:04:05"
	YYYYMMDDHHMM        = "2006-01-02 15:04"
	YYYYMMDDHH          = "2006-01-02 15"
	YYYYMMDD            = "2006-01-02"
	HHMMSS              = "15:04:05"
	HHMM                = "15:04"
	MMSS                = "04:05"
	YYYY                = "2006"
	MM1                 = "01"
	DD                  = "02"
	HH                  = "15"
	MM2                 = "04"
	SS                  = "05"
)

Variables

This section is empty.

Functions

func AesDecrypt

func AesDecrypt(crypted, key []byte) ([]byte, error)

func AesEncrypt

func AesEncrypt(origData, key []byte) ([]byte, error)

func FloatToInt

func FloatToInt(f float64) int64

func FloatToString

func FloatToString(f float64) string

func GenRsaKey

func GenRsaKey(bits int) error

生成 私钥和公钥文件

func InsertByte

func InsertByte(source []byte, i uint8, idx int64) []byte

func IntDateFmt

func IntDateFmt(date int64, inFmt string, outFmt string) string

func IntToFloat

func IntToFloat(i int64) float64

func IntToString

func IntToString(i int64) string

func IsDate

func IsDate(fmt, str string) bool

func Max added in v0.4.1

func Max(first float64, rest ...float64) float64

func Min added in v0.4.1

func Min(first float64, rest ...float64) float64

func PKCS7Padding

func PKCS7Padding(ciphertext []byte, blockSize int) []byte

func PKCS7UnPadding

func PKCS7UnPadding(origData []byte) []byte

func RandInt

func RandInt(max int64, min int64) int64

func RandIntString

func RandIntString(n int) string

func RandLowcase

func RandLowcase(n int) string

func RandMix

func RandMix(n int) string

func RandString

func RandString(n int, num bool, lowcase bool, upcase bool) string

func RandUpcase

func RandUpcase(n int) string

func Regexp

func Regexp(pattern string, s string) bool

func RsaDecrypt

func RsaDecrypt(ciphertext []byte) ([]byte, error)

私钥解密

func RsaEncrypt

func RsaEncrypt(data []byte) ([]byte, error)

公钥加密

func RsaSign

func RsaSign(data []byte) ([]byte, error)

私钥签名

func RsaSignVer

func RsaSignVer(data []byte, signature []byte) error

公钥验证

func StringDateFmt

func StringDateFmt(date, inFmt, outFmt string) string

func StringToFloat

func StringToFloat(s string) float64

func StringToFloatDecimal

func StringToFloatDecimal(s string, exp int32) float64

func StringToInt

func StringToInt(s string) int64

func StringsContains added in v0.5.0

func StringsContains(array []string, s string) bool

func StructToMap added in v0.3.1

func StructToMap(item interface{}) map[string]interface{}

func UnixString

func UnixString() string

Types

This section is empty.

Jump to

Keyboard shortcuts

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