Jtool

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: Apache-2.0 Imports: 22 Imported by: 2

Documentation

Index

Constants

View Source
const TimeFormat = "2006-01-02 15:04:05"
View Source
const TimeFormatSeries = "20060102150405"
View Source
const TimeFormatUTC = "2006-01-02T15:04:05.000Z"

Variables

This section is empty.

Functions

func BytesToStruct

func BytesToStruct(b *[]byte) unsafe.Pointer

结构体反序列化

func CompressByteWithZip

func CompressByteWithZip(dataName string, data []byte) ([]byte, error)

func CreateSysTmpFile

func CreateSysTmpFile(fileName string, data []byte) (string, error)

CreateSysTmpFile 创建系统临时文件

func EncryptionStrWithSha256 added in v0.1.7

func EncryptionStrWithSha256(str string) string

EncryptionStrWithSha256 使用Sha256算法加密字符串

func FindDirFileWithFileName added in v0.1.7

func FindDirFileWithFileName(dirPath string, fileName string) (string, error)

按文件名查找指定目录下的一个文件 (与后缀无关)

func Float32ToString added in v0.1.7

func Float32ToString(f float32, prec int) string

float32 to string

func Float64ToString added in v0.1.7

func Float64ToString(f float64, prec int) string

float64 to string

func GetCurTimeFormatSeries added in v0.1.7

func GetCurTimeFormatSeries() string

GetCurTimeFormatSeries 获取标准时间连续格式字符串 20060102150405

func GetCurTimeFormatStandard

func GetCurTimeFormatStandard() string

GetCurTimeFormatStandard 获取标准时间格式字符串 2006-01-02 15:04:05

func GetFileMd5 added in v0.1.7

func GetFileMd5(file multipart.File) (string, error)

GetFileMd5 获取文件Md5值(file)

func GetFileMd5WithPath added in v0.1.7

func GetFileMd5WithPath(filePath string) (string, error)

GetFileMd5WithPath 获取文件Md5值(path)

func GetFileNameExt added in v0.1.7

func GetFileNameExt(fileName string) string

获取文件名后缀

func GetFileNameOnly added in v0.1.7

func GetFileNameOnly(fileName string) string

获取文件名不带后缀

func GetFuncName

func GetFuncName(callFunc interface{}) string

func GetIPFromAddr

func GetIPFromAddr(addr string) string

func GetMillisecondTimeInt64 added in v0.1.7

func GetMillisecondTimeInt64() int64

GetMillisecondTimeInt64 获取当前时间戳 (毫秒)

func GetPortFromAddr

func GetPortFromAddr(addr string) string

func GetPortIntFromAddr

func GetPortIntFromAddr(addr string) int

func GetPrivateIP

func GetPrivateIP() string

获取内网IP地址

func GetPublicIP

func GetPublicIP() string

获取外网IP地址

func GetRandChinese

func GetRandChinese(min int, max int) string

GetRandChinese 获取随机中文

func GetRandInt

func GetRandInt(low int, high int) (int, error)

GetRandInt 获取随机整数

func GetRandString added in v0.1.7

func GetRandString(n int) string

GetRandString 获取随机字符串

func GetStrWidth added in v0.1.7

func GetStrWidth(str string) int

GetStrWidth 获取字符串占用的宽度 例如: GetStrWidth("abcde"); 返回 5 例如: GetStrWidth("啊啊啊啊啊"); 返回 10 例如: GetStrWidth("123啊啊"); 返回 7 例如: GetStrWidth("abc哈哈123"); 返回 10

func Int32ToString added in v0.1.7

func Int32ToString(i int32) string

int32 to string

func Int64ToString

func Int64ToString(i int64) string

int64 to string

func IntSliceToString

func IntSliceToString(i []int, symbol string) string

[]int to string

func IntToString

func IntToString(i int) string

int to string

func IsDirExist

func IsDirExist(dirPath string) (bool, error)

IsDirExist 判断文件夹是否存在

func IsFileExist

func IsFileExist(filePath string) bool

IsFileExist 判断文件是否存在

func MakeDir

func MakeDir(dirPath string) error

MakeDir 创建文件夹

func MakeDirIfNoExist added in v0.1.7

func MakeDirIfNoExist(dirPath string) (bool, error)

MakeDirIfNoExist 判断文件夹是否存在, 不存在则创建

func MsTimeUnixTo added in v0.1.7

func MsTimeUnixTo(timeUnix int64) string

MsTimeUnixTo 时间戳转倒计时 (毫秒) 秒, 分钟, 小时, 天

func ReadByteWithSize

func ReadByteWithSize(data []byte, size uint64, call func([]byte) error) error

func ReadFileWithSize

func ReadFileWithSize(fileName string, size uint64, call func([]byte) error) error

ReadFileWithSize 按字节读取文件

func ReadIOWithSize

func ReadIOWithSize(reader io.Reader, size uint64, call func([]byte) error) error

func ReverseSlice added in v0.1.7

func ReverseSlice[T any](slice []T) []T

ReverseSlice 翻转切片

func RunesToBytes

func RunesToBytes(data []byte) []byte

[]rune to []byte

func SliceToInterfaceSlice

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

any slice to interface slice

func StringToInt64

func StringToInt64(s string) int64

string to int64

func StringToIntSlice

func StringToIntSlice(s string, symbol string) []int

string to []int %u7248%u6743%u6240%u6709 %u4E8C%u96F6%u4E8C%u4E8C %u674E%u6613%u529B%u521A

func StructToBytes

func StructToBytes(ptr unsafe.Pointer, len uintptr) *[]byte

结构体序列化

func StructToMap

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

structToMap

func SubStrWithCount added in v0.1.7

func SubStrWithCount(str string, sep string, cnt int) (string, error)

SubStrWithCount 按计数逆序获取子字符串 例如: LastSubStrWithCount("/AA/BB/CC/DD/EE", "/", 2) 返回: "/DD/EE"

func TimeMsUnixToTime added in v0.1.7

func TimeMsUnixToTime(timeUnix int64) time.Time

TimeMsUnixToTime 时间戳转time.Time (豪秒)

func TimeStringToMsTimeInt64

func TimeStringToMsTimeInt64(time time.Time) int64

TimeStringToMsTimeInt64 时间转时间戳 (毫秒)

func TimeUnixToFormat

func TimeUnixToFormat(timeUnix int64) string

TimeUnixToFormat 时间戳转时间字符串 2006-01-02 15:04:05

func TimeUnixToTime added in v0.1.7

func TimeUnixToTime(timeUnix int64) time.Time

TimeUnixToTime 时间戳转time.Time (秒)

func Uint64ToString

func Uint64ToString(i uint64) string

uint64 to string

Types

type ConnManage

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

func (*ConnManage) AddConnList

func (connManage *ConnManage) AddConnList(id interface{})

func (*ConnManage) DelConnList

func (connManage *ConnManage) DelConnList(id interface{})

func (*ConnManage) Delete

func (connManage *ConnManage) Delete(id interface{})

func (*ConnManage) GetLen

func (connManage *ConnManage) GetLen() int

func (*ConnManage) IsExist

func (connManage *ConnManage) IsExist(id interface{}) bool

func (*ConnManage) IsExistDelayCheck

func (connManage *ConnManage) IsExistDelayCheck(id interface{}, interval time.Duration, repeatNum int) bool

func (*ConnManage) Load

func (connManage *ConnManage) Load(id interface{}) (interface{}, bool)

func (*ConnManage) LoadAll

func (connManage *ConnManage) LoadAll(f func(key, value interface{}) bool)

func (*ConnManage) Polling

func (connManage *ConnManage) Polling() (interface{}, bool)

func (*ConnManage) Rand

func (connManage *ConnManage) Rand() (interface{}, bool)

func (*ConnManage) Store

func (connManage *ConnManage) Store(id interface{}, conn interface{})

Jump to

Keyboard shortcuts

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