utils

package
v0.0.0-...-5893fcd Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Any2Arr

func Any2Arr(data interface{}) []interface{}

Any2Arr interface{} -> []interface{}

func Any2Int

func Any2Int(data interface{}) int

Any2Int interface{} -> int

func Any2Json

func Any2Json(data interface{}) (string, error)

Any2Json interface{} -> json string

func Any2JsonB

func Any2JsonB(data interface{}) ([]byte, error)

Any2Json interface{} -> json string

func Any2Map

func Any2Map(data interface{}) map[string]interface{}

Any2Map interface{} -> map[string]interface{}

func BeginDayUnix

func BeginDayUnix() int64

BeginDayUnix 获取当天凌晨的时间戳

func BeginDayUnixStr

func BeginDayUnixStr() string

BeginDayUnixStr

func Compress

func Compress(files []string, dest string) error

Compress 压缩文件 files 文件数组,可以是不同dir下的文件或者文件夹 dest 压缩文件存放地址

func DayAgo

func DayAgo(i int) int64

DayAgo 获取多少天前的时间戳

func Daydiff

func Daydiff(beginDay string, endDay string) int

Daydiff 两个时间字符串的日期差

func DeCompressTAR

func DeCompressTAR(tarFile, dest string) error

DeCompressTAR tar 解压文件

func DeCompressZIP

func DeCompressZIP(zipFile, dest string) error

DeCompressZIP zip解压文件

func DecompressionZipFile

func DecompressionZipFile(src, dest string) error

DecompressionZipFile zip压缩文件

func DeletePreAndSufSpace

func DeletePreAndSufSpace(str string) string

DeletePreAndSufSpace 删除字符串前后两端的所有空格

func EndDayUnix

func EndDayUnix() int64

EndDayUnix 获取当天24点的时间戳

func EndDayUnixStr

func EndDayUnixStr() string

EndDayUnixStr

func Get16MD5Encode

func Get16MD5Encode(data string) string

Get16MD5Encode 返回一个16位md5加密后的字符串

func GetAllFile

func GetAllFile(pathname string) ([]string, error)

GetAllFile 获取目录下的所有文件

func GetCpuCoreNumber

func GetCpuCoreNumber() string

GetCpuCoreNumber 获取cpu核心数

func GetHostName

func GetHostName() string

GetHostName 获取host 命名

func GetMD5Encode

func GetMD5Encode(data string) string

GetMD5Encode

func GetMyIP

func GetMyIP() string

GetMyIP 获取本机ip

func GetNetInfo

func GetNetInfo() error

GetNetInfo 获取网卡信息

func GetSysArch

func GetSysArch() string

GetSysArch 获取系统架构

func GetSysType

func GetSysType() string

GetSysType 获取host 系统类型

func HTTPDownLoad

func HTTPDownLoad(url, filePath string) (string, error)

HTTPDownLoad 下载 TODO 多线程下载

func HourAgo

func HourAgo(i int) int64

HourAgo 获取多少小时前的时间戳

func ID64

func ID64() (int64, error)

ID64

func IDMd5

func IDMd5() string

IDMd5

func IDStr

func IDStr() string

IDStr

func Int642Str

func Int642Str(i int64) string

Int642Str int64 -> string

func IsHaveKey

func IsHaveKey(data map[string]interface{}, key string) bool

IsHaveKey map[string]interface{} 是否存在 输入的key

func IsJson

func IsJson(str string) bool

IsJson 是否是json格式

func Json2Map

func Json2Map(str string) (map[string]interface{}, error)

Json2Map json -> map

func JsonFind

func JsonFind(jsonStr, find string) (interface{}, error)

JsonFind 按路径寻找指定json值 find : 寻找路径,与目录的url类似, 下面是一个例子: json: {a:[{b:1},{b:2}]} find=/a/[0] => {b:1} find=a/[0]/b => 1

func MD5String

func MD5String(v string) string

MD5String 字符串md5值

func Md5BigFile

func Md5BigFile(path string) (string, error)

Md5BigFile 文件求md5值 - 大文件

func Md5SmallFile

func Md5SmallFile(path string) (string, error)

Md5SmallFile 文件求md5值 - 小文件

func MinuteAgo

func MinuteAgo(i int) int64

MinuteAgo 获取多少分钟前的时间戳

func NowTimeStr

func NowTimeStr() string

NowTimeStr 获取当前时间

func NowTimeStrHMS

func NowTimeStrHMS() string

NowTimeStrHMS 获取当前时间

func NowUninx

func NowUninx() int64

NowUninx

func NowUninxStr

func NowUninxStr() string

NowUninxStr

func Num2Int

func Num2Int(s string) int

Num2Int 数字类字符串 转 int

func Num2Int64

func Num2Int64(s string) int64

Num2Int64 数字类字符串 转 int64

func PathExists

func PathExists(path string) (bool, error)

PathExists 文件是否存在

func RegFindAll

func RegFindAll(regStr, rest string) (dataList []string)

RegFindAll

func SliceDifference

func SliceDifference(slice1, slice2 []string) []string

SliceDifference 切片差集

func SliceIntersect

func SliceIntersect(slice1 []string, slice2 []string) []string

SliceIntersect 切片交集

func Str2Int

func Str2Int(s string) int

Str2Int 字符串转int

func Str2Int64

func Str2Int64(s string) int64

Str2Int64 字符串转int64

func StringValue

func StringValue(i interface{}) string

StringValue 任何类型返回值字符串形式

func SysInfo

func SysInfo()

SysInfo 获取系统信息

func Tcper

func Tcper(ip string) bool

Tcper

func TickerRun

func TickerRun(t time.Duration, runFirst bool, f func())

TickerRun 间隔运行 t: 间隔时间, runFirst: 间隔前或者后执行 f: 运行的方法

func Uinx2Date

func Uinx2Date(timeStamp int64) string

Uinx2Date 时间戳转日期

Types

type IdWorker

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

IdWorker

func (*IdWorker) InitIdWorker

func (idw *IdWorker) InitIdWorker(workerId, datacenterId int64) error

InitIdWorker

func (*IdWorker) NextId

func (idw *IdWorker) NextId() (int64, error)

NextId 返回一个唯一的 INT64 ID

type JWT

type JWT struct {
	Claims jwt.MapClaims
	Secret string
	Expire int
}

func NewJWT

func NewJWT() *JWT

func (*JWT) AddClaims

func (j *JWT) AddClaims(k string, v interface{}) *JWT

func (*JWT) Get

func (j *JWT) Get(k string) interface{}

func (*JWT) GetBool

func (j *JWT) GetBool(k string) bool

func (*JWT) GetFloat64

func (j *JWT) GetFloat64(k string) float64

func (*JWT) GetInt

func (j *JWT) GetInt(k string) int

func (*JWT) GetInt64

func (j *JWT) GetInt64(k string) int64

func (*JWT) GetString

func (j *JWT) GetString(k string) string

func (*JWT) IsExpire

func (j *JWT) IsExpire() bool

func (*JWT) ParseToken

func (j *JWT) ParseToken(token string) error

func (*JWT) Print

func (j *JWT) Print()

func (*JWT) Token

func (j *JWT) Token() (string, error)

Jump to

Keyboard shortcuts

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