util

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AESCBCDecrypt added in v0.3.0

func AESCBCDecrypt(cryted string, key string) (string, error)

func AESCBCEncrypt added in v0.3.0

func AESCBCEncrypt(orig string, key string) (string, error)

func CommonPrefix added in v0.4.0

func CommonPrefix(arr []string) string

func CreatePath added in v0.2.0

func CreatePath(filePath string) error

func DeepCopy added in v0.3.0

func DeepCopy(dst, src interface{}) error

深度拷贝

func Diff

func Diff(a map[string]interface{}, b map[string]interface{}) map[string]interface{}

Diff ..

func DiffList added in v0.2.0

func DiffList(source, dest interface{}, cmp func(a, b interface{}) bool) (res []interface{})

DiffList 求 source 和 dest 的 交/差集 此函数效率较低(O(n^2)),请在列表长度较小时使用

func DiffListToSlice added in v0.3.0

func DiffListToSlice(source, dest interface{}, cmp func(a, b interface{}) bool) (res interface{})

DiffListToSlice 求 source 和 dest 的 交/差集,返回类型和 source 相同

func ExternalIP added in v0.4.0

func ExternalIP() (net.IP, error)

func ExternalIPString added in v0.4.0

func ExternalIPString() string

func FindIndex added in v0.4.0

func FindIndex(arr interface{}, item interface{}, cmp func(a, b interface{}) bool) (index int)

FindIndex 查找 item 在 arr 里的下标,通过 cmp 函数进行列表项相等判断 如果不存在则返回 -1

func FormValueArray added in v0.2.0

func FormValueArray(key string, postForm url.Values) []string

FormValueArray 从post form中获取数组参数

func GetTodayZeroPoint added in v0.2.0

func GetTodayZeroPoint() int64

GetTodayZeroPoint ..

func GetTodayZeroPointTime added in v0.2.0

func GetTodayZeroPointTime() time.Time

GetTodayZeroPointTime ..

func GetTyp added in v0.2.0

func GetTyp(typeStr string) (typ reflect.Kind, err error)

func GetVal added in v0.2.0

func GetVal(val string, typeStr string) (result interface{}, typ reflect.Kind, err error)

func GetYesterdayZeroPoint added in v0.2.0

func GetYesterdayZeroPoint() int64

GetYesterdayZeroPoint ..

func InArray added in v0.2.0

func InArray(val string, arr []string) (index int, exist bool)

InArray 会判断var是否在arr中。

func IntNumberSet added in v0.2.0

func IntNumberSet(ids []int) []int

IntNumberSet ...

func IsExist added in v0.2.0

func IsExist(path string) bool

FileExists reports whether the named file or directory exists.

func IsFileExists added in v0.2.0

func IsFileExists(path string) (bool, error)

IsFileExists ...

func Md5 added in v0.2.0

func Md5(s string) string

md5

func Md5Bytes added in v0.2.0

func Md5Bytes(data []byte) string

Md5Bytes ...

func Md5File added in v0.2.0

func Md5File(path string) string

Md5File ...

func Md5Str added in v0.2.0

func Md5Str(val string) string

func Now added in v0.2.0

func Now() int64

Now 返回当前时间戳。

func PKCS7Padding added in v0.3.0

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

补码, len = 128||192||256 AES加密数据块分组长度必须为128bit(byte[16]),密钥长度可以是128bit(byte[16])、192bit(byte[24])、256bit(byte[32])中的任意一个。

func PKCS7UnPadding added in v0.3.0

func PKCS7UnPadding(origData []byte) []byte

去码

func ParseAddr added in v0.2.0

func ParseAddr(tplType, addr string) (ip string, port, user, psw string)

ParseAddr ...

func ParseRedisAddr added in v0.2.0

func ParseRedisAddr(addrOrigin string) (addr string)

ParseRedisAddr ...

func RemoveDuplicatesAndEmpty added in v0.2.0

func RemoveDuplicatesAndEmpty(a []string) (ret []string)

RemoveDuplicatesAndEmpty 去重

func ShortHash added in v0.2.0

func ShortHash(longstr string, number int) string

生成短hash

func String2Timestamp added in v0.2.0

func String2Timestamp(str string) int64

String2Timestamp 会将当前时间转换为时间戳。

func StringInArray added in v0.2.0

func StringInArray(needle string, haystack []string) bool

func StringPkg added in v0.2.0

func StringPkg(str string) (ok bool, depth int)

判断是否是一个go包字符串

func StringToInt64 added in v0.2.0

func StringToInt64(s string) int64

字符串转int64

func Substr added in v0.2.0

func Substr(str string, start int, length int) string

字符串截取

func Timestamp2String added in v0.2.0

func Timestamp2String(timestamp int) string

Timestamp2String 会格式化当前时间。

func Timestamp2String64 added in v0.2.0

func Timestamp2String64(timestamp int64) string

Types

type DSN added in v0.2.0

type DSN struct {
	User   string            // Username
	Passwd string            // Password (requires User)
	Net    string            // Network type
	Addr   string            // Network address (requires Net)
	DBName string            // Database name
	Params map[string]string // Connection parameters
}

DSN ...

func ParseDSN added in v0.2.0

func ParseDSN(dsn string) (cfg *DSN, err error)

ParseDSN parses the DSN string to a Config

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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