misc

package module
v1.2.8 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2019 License: Unlicense Imports: 27 Imported by: 0

README

misc

大杂烩

Documentation

Overview

misc document

tools project tools.go

Index

Constants

This section is empty.

Variables

View Source
var ErrorTimeout = errors.New("timeout")

ErrorTimeout ....

Functions

func BytesToInt16

func BytesToInt16(b []byte) int16

func BytesToInt16A

func BytesToInt16A(b []byte, offset int) int16

func BytesToInt24

func BytesToInt24(b []byte) int32

func BytesToInt24A

func BytesToInt24A(b []byte, offset int) int32

func BytesToInt32

func BytesToInt32(b []byte) int32

func BytesToInt32A

func BytesToInt32A(b []byte, offset int) int32

func BytesToInt64

func BytesToInt64(array []byte) int64

func BytesToInt64A

func BytesToInt64A(array []byte, offset int) int64

func BytesToUint16

func BytesToUint16(array []byte) uint16

func BytesToUint16A

func BytesToUint16A(array []byte, offset int) uint16

func BytesToUint24

func BytesToUint24(array []byte) uint32

func BytesToUint24A

func BytesToUint24A(array []byte, offset int) uint32

func BytesToUint32

func BytesToUint32(array []byte) uint32

func BytesToUint32A

func BytesToUint32A(array []byte, offset int) uint32

func CoarseTimeNow

func CoarseTimeNow() time.Time

CoarseTimeNow ....

func DateTime

func DateTime(pattern string) string

func Exec

func Exec(command string, wait bool, args ...string) error

func Exist

func Exist(filename string) bool

Exist ....

func Fill

func Fill(prefix string, v interface{}) error

func GenRSAKey

func GenRSAKey(bits int) (priv_key, pub_key []byte, err error)

生成RSA密钥对

func GetArray

func GetArray(m map[string]interface{}, key string) ([]interface{}, bool)

GetArray ....

func GetFloat

func GetFloat(m map[string]interface{}, key string) (float64, bool)

GetFloat ....

func GetInt

func GetInt(m map[string]interface{}, key string) (int64, bool)

GetInt ....

func GetMap

func GetMap(m map[string]interface{}, key string) (map[string]interface{}, bool)

GetMap ....

func GetObject

func GetObject(m map[string]interface{}, key string, obj interface{}) bool

GetObject ....

func GetRealIp

func GetRealIp(req *http.Request) string

func GetRefererDomain

func GetRefererDomain(req *http.Request) string

func GetString

func GetString(m map[string]interface{}, key string) (string, bool)

GetString ....

func GetUrlPath

func GetUrlPath(rawurl string) string

func HMAC_SHA256

func HMAC_SHA256(key []byte, b []byte) []byte

func Int16ToBytes

func Int16ToBytes(n int16) [2]byte

func Int16ToBytesA

func Int16ToBytesA(n int16, array []byte, offset int)

func Int24ToBytes

func Int24ToBytes(n int32) [3]byte

func Int24ToBytesA

func Int24ToBytesA(n int32, array []byte, offset int)

func Int32ToBytes

func Int32ToBytes(n int32) [4]byte

func Int32ToBytesA

func Int32ToBytesA(n int32, array []byte, offset int)

func Int64ToBytes

func Int64ToBytes(n int64) [8]byte

func Int64ToBytesA

func Int64ToBytesA(n int64, array []byte, offset int)

func Ip2long

func Ip2long(ipstr string) (ip uint32)

func Long2ip

func Long2ip(ip uint32) string

func MD5

func MD5(b []byte) []byte

func PutUint16_Big

func PutUint16_Big(b []byte, v uint16)

func PutUint16_Little

func PutUint16_Little(b []byte, v uint16)

func PutUint24_Big

func PutUint24_Big(b []byte, v uint32)

func PutUint24_Little

func PutUint24_Little(b []byte, v uint32)

func PutUint32_Big

func PutUint32_Big(b []byte, v uint32)

func PutUint32_Little

func PutUint32_Little(b []byte, v uint32)

func PutUint64_Big

func PutUint64_Big(b []byte, v uint64)

func PutUint64_Little

func PutUint64_Little(b []byte, v uint64)

func RSADecrypt

func RSADecrypt(encrypt, priv_key []byte) (data []byte, err error)

RSA私钥解密

func RSAEncrypt

func RSAEncrypt(origData, pub_key []byte) (encrypt []byte, err error)

RSA公钥加密

func ReadBytes

func ReadBytes(req *http.Request) ([]byte, error)

func ReadContent

func ReadContent(req *http.Request) (content string, err error)

func SHA1

func SHA1(b []byte) []byte

func SHA256

func SHA256(b []byte) []byte

func SHA512

func SHA512(b []byte) []byte

func SleepMilliSecond

func SleepMilliSecond(millsecond int)

func TimeFormat

func TimeFormat(format string, t time.Time) string

TimeFormat ....

func Timestamp

func Timestamp() string

func TimestampByPattern

func TimestampByPattern(p string) string

func URLEncode

func URLEncode(rawurl string) string

func UUID

func UUID() string

UUID ....

func Uint16ToBytes

func Uint16ToBytes(n uint16) [2]byte

func Uint16ToBytesA

func Uint16ToBytesA(n uint16, array []byte, offset int)

func Uint16_Big

func Uint16_Big(b []byte) uint16

func Uint16_Little

func Uint16_Little(b []byte) uint16

func Uint24ToBytes

func Uint24ToBytes(n uint32) [3]byte

func Uint24ToBytesA

func Uint24ToBytesA(n uint32, array []byte, offset int)

func Uint24_Big

func Uint24_Big(b []byte) uint32

func Uint24_Little

func Uint24_Little(b []byte) uint32

func Uint32ToBytes

func Uint32ToBytes(n uint32) [4]byte

func Uint32ToBytesA

func Uint32ToBytesA(n uint32, array []byte, offset int)

func Uint32_Big

func Uint32_Big(b []byte) uint32

func Uint32_Little

func Uint32_Little(b []byte) uint32

func Uint64_Big

func Uint64_Big(b []byte) uint64

func Uint64_Little

func Uint64_Little(b []byte) uint64

Types

type Env

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

func (*Env) Fill

func (e *Env) Fill(prefix string, v interface{}) error

type PersistQueue

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

PersistQueue ....

func NewPersistQueue

func NewPersistQueue(path string, bufsize int) (*PersistQueue, error)

NewPersistQueue 创建一个持久队列,path为队列目录,bufsize为缓冲区大小,ssd硬盘单队列测试下来每秒20000左右

func (*PersistQueue) Close

func (q *PersistQueue) Close() error

Close ....

func (*PersistQueue) Delete

func (q *PersistQueue) Delete() error

Delete ....

func (*PersistQueue) Empty

func (q *PersistQueue) Empty() error

Empty ....

func (*PersistQueue) Poll

func (q *PersistQueue) Poll(msg interface{}) error

Poll ...

func (*PersistQueue) PollTimeout

func (q *PersistQueue) PollTimeout(msg interface{}, timeout time.Duration) error

PollTimeout ...

func (*PersistQueue) Put

func (q *PersistQueue) Put(msg interface{}) error

Put ....

func (*PersistQueue) Size

func (q *PersistQueue) Size() uint64

Size ....

type WorkerFunc

type WorkerFunc = func()

WorkerFunc ....

type WorkerPool

type WorkerPool struct {
	MaxWorkersCount int

	LogAllErrors bool

	MaxIdleWorkerDuration time.Duration
	// contains filtered or unexported fields
}

WorkerPool Such a scheme keeps CPU caches hot (in theory).

func (*WorkerPool) Serve

func (wp *WorkerPool) Serve(f WorkerFunc) bool

Serve ....

func (*WorkerPool) Start

func (wp *WorkerPool) Start()

Start ....

func (*WorkerPool) Stop

func (wp *WorkerPool) Stop()

Stop ....

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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