util

package
v0.0.0-...-1c5b680 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2019 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckError

func CheckError(err error)

func CompressBytes

func CompressBytes(data []byte) ([]byte, error)

func DecompressBytes

func DecompressBytes(data []byte) ([]byte, error)

func FileExists

func FileExists(name string) bool

func FileSize

func FileSize(name string) int64

func FloatToString

func FloatToString(num interface{}, fixedLen int) string

Float转成字符串

func GenKey8

func GenKey8() (string, error)

func GetLocalIp

func GetLocalIp() string

获取本机Ip

func If

func If(condition bool, trueVal, falseVal interface{}) interface{}

三元表达式

func IsEOFOrNetReadError

func IsEOFOrNetReadError(err error) bool

判断网络错误

func NewErrCxt

func NewErrCxt(s string, context interface{}) error

func NewError

func NewError(s string) error

func NumToString

func NumToString(num interface{}) string

数字转成字符串

func PrintPanicStack

func PrintPanicStack()

func PrintPanicStackError

func PrintPanicStackError()

func ReadFileLines

func ReadFileLines(filename string, callback func(line string) bool) error

func Run

func Run()

保持进程

func StackToString

func StackToString(count int) string

func UnixMillisecond

func UnixMillisecond() int64

获取当前毫秒时间戳

func WriteFull

func WriteFull(writer io.Writer, buf []byte) error

Types

type Error

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

func (*Error) Error

func (self *Error) Error() string

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)

type Worker

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

定义一个woker工作节点所需要的基本参数

func NewWorker

func NewWorker(workerId int64) (*Worker, error)

实例化一个工作节点

func (*Worker) GetId

func (w *Worker) GetId() int64

接下来我们开始生成id 生成方法一定要挂载在某个woker下,这样逻辑会比较清晰 指定某个节点生成id

Jump to

Keyboard shortcuts

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