util

package
v0.0.0-...-b22f859 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: BSD-3-Clause Imports: 32 Imported by: 0

Documentation

Overview

Copyright (c) 2023, donnie <donnie4w@gmail.com> All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

github.com/donnie4w/tldb

Copyright (c) 2023, donnie <donnie4w@gmail.com> All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

github.com/donnie4w/tldb

Index

Constants

This section is empty.

Variables

View Source
var BufferPool = gobuffer.NewBufferPool(8)
View Source
var GoPool = gopool.NewPool(200, sys.GOMAXLIMIT)

Functions

func ArrayContain

func ArrayContain[T int | int8 | int32 | int64 | string](a []T, v T) (b bool)

func ArrayEqual

func ArrayEqual[T int | int8 | int32 | int64 | string](a, b []T) bool

func ArraySliceAsc

func ArraySliceAsc[T int | int8 | int32 | int64 | string](a []T) (_r []T)

func ArraySub

func ArraySub[K int | int8 | int32 | int64 | string](a1, a2 []K) (_r []K)

func ArraySub2

func ArraySub2[K int | int8 | int32 | int64 | string](a []K, k K) (_r []K)

func ArraySubMap

func ArraySubMap[K int | int8 | int32 | int64 | string, V any](a []K, m *MapL[K, V]) (_r []K)

func ArrayToMap

func ArrayToMap[K int | int8 | int32 | int64 | string, V int8](a []K) (_r *Map[K, V])

func ArrayToMap2

func ArrayToMap2[K int | int8 | int32 | int64 | string, V any](a []K, v V) (_r map[K]V)

func BytesToInt16

func BytesToInt16(bs []byte) (_r int16)

func BytesToInt32

func BytesToInt32(bs []byte) (_r int32)

func BytesToInt64

func BytesToInt64(bs []byte) (_r int64)

func BytesToIntArray

func BytesToIntArray(bs []byte) (data []int64)

func CRC32

func CRC32(bs []byte) uint32

func CRC64

func CRC64(bs []byte) uint64

func CheckGzip

func CheckGzip(bs []byte) (err error)

func Concat

func Concat(ss ...string) string

func Decode

func Decode(buf []byte, e any) (err error)

func Encode

func Encode(e any) (by []byte, err error)

func Errors

func Errors(code sys.ErrCodeType) error

func Gzip

func Gzip(gzfname, srcfname, dir string) (err error)

func GzipWrite

func GzipWrite(bs []byte) (buf bytes.Buffer, err error)

func Hash

func Hash(key []byte) uint64

func Int16ToBytes

func Int16ToBytes(n int16) (bs []byte)

func Int32ToBytes

func Int32ToBytes(n int32) (bs []byte)

func Int64ToBytes

func Int64ToBytes(n int64) (bs []byte)

func IntArrayToBytes

func IntArrayToBytes(n []int64) []byte

func IsFileExist

func IsFileExist(path string) (_r bool)

func MD5

func MD5(s string) string

func Map2SyncMap

func Map2SyncMap[K int | int8 | int32 | int64 | string, V any](m1 map[K]V) (m2 *Map[K, V])

func MapSub

func MapSub[K int | int8 | int32 | int64 | string, V any](m1, m2 *MapL[K, V]) (_r *MapL[K, V])

func MapToArray

func MapToArray[K int | int8 | int32 | int64 | string, V any](m *Map[K, V]) (_r []K)

func MapToArray2

func MapToArray2[K int | int8 | int32 | int64 | string, V any](m map[K]V) (_r []K)

func MatchString

func MatchString(pattern string, s string) bool

func NewTsLockPool

func NewTsLockPool() *_tsLockPool

func NewTxId

func NewTxId() (txid int64)

func NewUUID

func NewUUID() uint32

func Rand

func Rand(i int) (_r int)

func RandStrict

func RandStrict(i int64) (_r int64, _err error)

func ReadFile

func ReadFile(path string) (bs []byte, err error)

func Recovr

func Recovr()

func SHA1

func SHA1(s string) string

func SnappyDecode

func SnappyDecode(bs []byte) (_r []byte)

func SnappyEncode

func SnappyEncode(bs []byte) (_r []byte)

func SyncMap2Map

func SyncMap2Map[K int | int8 | int32 | int64 | string, V any](m1 *Map[K, V]) (m2 map[K]V)

func TDecode

func TDecode[T thrift.TStruct](bs []byte, ts T) (_r T, err error)

func TEncode

func TEncode(ts thrift.TStruct) (_r []byte)

func Time

func Time() time.Time

func TimeNano

func TimeNano() int64

func TimeStr

func TimeStr() string

func TimeStrToTime

func TimeStrToTime(s string) (t time.Time, err error)

func UnGzip

func UnGzip(bs []byte) (_bb bytes.Buffer, err error)

func UnGzipByBytes

func UnGzipByBytes(bs []byte, f func(bs []byte) bool) (err error)

func UnGzipByFile

func UnGzipByFile(gzfname string, f func(bs []byte) bool)

func ZlibCz

func ZlibCz(bs []byte) (_r []byte, err error)

func ZlibUnCz

func ZlibUnCz(bs []byte) (_r []byte, err error)

Types

type Await

type Await[T any] struct {
	// contains filtered or unexported fields
}

*******************************************************

func NewAwait

func NewAwait[T any](muxlimit int) *Await[T]

func (*Await[T]) DelAndClose

func (this *Await[T]) DelAndClose(idx int64)

func (*Await[T]) DelAndPut

func (this *Await[T]) DelAndPut(idx int64, v T)

func (*Await[T]) Get

func (this *Await[T]) Get(idx int64) (ch chan T)

type LimitLock

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

*******************************************************

func NewLimitLock

func NewLimitLock(limit int, timeout time.Duration) (_r *LimitLock)

func (*LimitLock) Cc

func (this *LimitLock) Cc() int64

concurrency num

func (*LimitLock) Lock

func (this *LimitLock) Lock() (err error)

func (*LimitLock) LockCount

func (this *LimitLock) LockCount() int64

func (*LimitLock) Unlock

func (this *LimitLock) Unlock()

type Numlock

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

func NewNumLock

func NewNumLock(muxNum int) *Numlock

func (*Numlock) Lock

func (this *Numlock) Lock(key int64)

func (*Numlock) Unlock

func (this *Numlock) Unlock(key int64)

type Strlock

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

***************************************************

func NewStrlock

func NewStrlock(muxNum int) *Strlock

func (*Strlock) Lock

func (this *Strlock) Lock(key string)

func (*Strlock) RLock

func (this *Strlock) RLock(key string)

func (*Strlock) RUnlock

func (this *Strlock) RUnlock(key string)

func (*Strlock) Unlock

func (this *Strlock) Unlock(key string)

type TlLock

type TlLock[T any] interface {
	Lock(key T)
	UnLock(key T)
}

type TsLock

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

*******************************************************

func (*TsLock) GetKey

func (this *TsLock) GetKey() []string

func (*TsLock) Lock

func (this *TsLock) Lock()

func (*TsLock) UnLock

func (this *TsLock) UnLock()

Jump to

Keyboard shortcuts

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