util

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreatePath added in v0.2.0

func CreatePath(filePath string) error

func Diff

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

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 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 ParseAddr added in v0.2.0

func ParseAddr(addr string) (ip string, port 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