utils

package
v0.0.0-...-67d91c4 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2022 License: MIT Imports: 20 Imported by: 42

Documentation

Index

Constants

View Source

Variables

This section is empty.

Functions

func Any2String

func Any2String(i interface{}) string

Any2String interface{} -> string

func CheckFileExist

func CheckFileExist(fileName string) bool

检查文件是否存在

func Compressed

func Compressed(cache string) []byte

Compressed 压缩字符串

func Decompress

func Decompress(data []byte) string

Decompress 解压字符串

func DeepCopy

func DeepCopy(dst, src interface{}) error

深 copy 对象

func FileRead

func FileRead(fileName string) ([]byte, error)

读取文件

func FileWrite

func FileWrite(fileName string, data []byte)

文件写入数据

func GetIp

func GetIp() (string, error)

func GetLocalIP

func GetLocalIP() (string, error)

GetLocalIP

func GobDecoder

func GobDecoder(data []byte) (res string)

func GobEncodeStr

func GobEncodeStr(data string) []byte

GobEncodeStr 将数据gob序列化存储到文件

func ID64

func ID64() (int64, error)

func IDStr

func IDStr() string

func Int642Str

func Int642Str(i int64) string

func LocalIPv4s

func LocalIPv4s() ([]string, error)

LocalIPs return all non-loopback IPv4 addresses

func MD5

func MD5(str string) string

func P2E

func P2E()

P2E panic -> error

func RandInt

func RandInt(min, max int) int

func SliceDelNullString

func SliceDelNullString(sli []string) []string

切片去除空元素

func Str2Bool

func Str2Bool(str string) bool

func Str2Float64

func Str2Float64(str string) float64

Str2Float string -> float64

func Str2Int

func Str2Int(str string) int

Str2Int64 string -> int

func Str2Int32

func Str2Int32(str string) int32

Str2Int64 string -> int32

func Str2Int64

func Str2Int64(str string) int64

Str2Int64 string -> int64

func Str2Timestamp

func Str2Timestamp(str string) int64

格式为 2006-01-02 15:04:05

func Str2TimestampStr

func Str2TimestampStr(str string) string

func Timestamp2Time

func Timestamp2Time(timestamp int64, layout string) string

Timestamp2Time 时间戳到时间 use : Timestamp2Time(time.Now().Unix(), "20060102 15:04:05")

Types

type IdWorker

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

func (*IdWorker) InitIdWorker

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

func (*IdWorker) NextId

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

返回一个唯一的 INT64 ID

Jump to

Keyboard shortcuts

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