util

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Addr2Hex

func Addr2Hex(str string) (string, error)

Addr2Hex converts address string to hex string, only support ipv4.

func CRC16

func CRC16(buf string) uint16

CRC16 returns the CRC-16 checksum of data.

func FunctionName

func FunctionName(i interface{}, seps ...rune) string

FunctionName returns function'name

func GenerateID

func GenerateID() string

GenerateID simply generates an Aid.

func GenerateUUID

func GenerateUUID(seedTime time.Time) string

GenerateUUID simply generates an unique UID.

func Go

func Go(fn func())

Go goroutine

func Hex2Addr

func Hex2Addr(str string) (string, error)

Hex2Addr converts hex string to address.

func JoinError

func JoinError(errs ...interface{}) error

func JsonString

func JsonString(obj interface{}) string

func LimitParallel

func LimitParallel(restrict int, fns ...func()) func()

LimitParallel 并发,最大并发量restrict

func MaxInt

func MaxInt(a, b int) int

func MinInt

func MinInt(a, b int) int

func MinInt64

func MinInt64(a, b int64) int64

func Parallel

func Parallel(fns ...func()) func()

Parallel 并发执行

func Ping

func Ping(addr string) error

Ping returns if address is invalid

func SafeGo

func SafeGo(fn func(), rec func(error))

SafeGo safe go

func Serial

func Serial(fns ...func()) func()

Serial 串行

Types

type Mutex

type Mutex struct {
	sync.Mutex
}

Mutex mutext with TryLock

func (*Mutex) TryLock

func (m *Mutex) TryLock() bool

TryLock try lock

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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