Documentation ¶
Overview ¶
Package util provides tiny featured funcs.
Index ¶
- Variables
- func AwareContext(ctx context.Context, f func() error) error
- func BatchWork(ctx context.Context, size, limit uint64, ...) error
- func BigBytesToInt64(b []byte) (int64, error)
- func BytesToInt64(b []byte) (int64, error)
- func BytesToUint64(b []byte) (uint64, error)
- func CheckIsValiderSlice[T IsValider](b []byte, allowNil bool, vs []T) error
- func CheckIsValiders(b []byte, allowNil bool, vs ...IsValider) error
- func CleanDirectory(root string, filter func(path string) bool) error
- func ConcatByterSlice[T Byter](bs []T) []byte
- func ConcatByters(bs ...Byter) []byte
- func ConcatBytesSlice(sl ...[]byte) []byte
- func CountFilteredSlice[T any](s []T, f func(T) bool) (n int)
- func DecodeHash(s string) []byte
- func EncodeHash(b []byte) string
- func EnsureRead(r io.Reader, b []byte) (int, error)
- func Filter2Slices[T any, Y any](a []T, b []Y, f func(T, Y) bool) []T
- func FilterMap[T any, Y comparable](s map[Y]T, f func(Y, T) bool) []T
- func FilterSlice[T any](s []T, f func(T) bool) []T
- func Float64ToBytes(i float64) []byte
- func FuncCaller(skip int) errors.Frame
- func InSlice[T comparable](s []T, n T) int
- func InSliceFunc[T any](s []T, f func(T) bool) int
- func Int64ToBigBytes(i int64) []byte
- func Int64ToBytes(i int64) []byte
- func InterfaceSetValue(v, target interface{}) error
- func IsDuplicatedSlice[T any](s []T, keyf func(T) (bool, string)) (map[string]T, bool)
- func IsNilJSON(b []byte) bool
- func IsValidURL(u *url.URL) error
- func LengthedBytes(w io.Writer, b []byte) error
- func LoadFromContext(ctx context.Context, a ...interface{}) error
- func LoadFromContextOK(ctx context.Context, a ...interface{}) error
- func MarshalJSON(v interface{}) ([]byte, error)
- func MarshalJSONIndent(i interface{}) ([]byte, error)
- func MustMarshalJSON(i interface{}) []byte
- func MustMarshalJSONIndent(i interface{}) []byte
- func MustMarshalJSONIndentString(i interface{}) string
- func NewLengthedBytesSlice(version byte, m [][]byte) ([]byte, error)
- func NormalizeTime(t time.Time) time.Time
- func ParseDuration(s string) (time.Duration, error)
- func ParseRFC3339(s string) (time.Time, error)
- func RFC3339(t time.Time) string
- func ReadLengthedBytes(b []byte) (_ []byte, left []byte, _ error)
- func ReadLengthedBytesFromReader(r io.Reader) ([]byte, error)
- func ReadLengthedBytesSlice(b []byte) (version byte, m [][]byte, left []byte, _ error)
- func Retry(ctx context.Context, f func() (bool, error), limit int, interval time.Duration) error
- func RunDistributeWorker(ctx context.Context, size uint64, errch chan error, ...) error
- func RunErrgroupWorker(ctx context.Context, size uint64, ...) error
- func RunErrgroupWorkerByJobs(ctx context.Context, jobs ...ContextWorkerCallback) error
- func SHA256Checksum(b []byte) string
- func StringErrorFunc(m string, a ...interface{}) func(error, string, ...interface{}) error
- func TimeEqual(a, b time.Time) bool
- func TimeString(t time.Time) string
- func TraverseSlice[T any](s []T, f func(int, T) error) error
- func ULID() ulid.ULID
- func UUID() uuid.UUID
- func Uint64ToBigBytes(i uint64) []byte
- func Uint64ToBytes(i uint64) []byte
- func Uint8ToBytes(i uint8) []byte
- func UintToBytes(i uint) []byte
- func UnmarshalJSON(b []byte, v interface{}) error
- func WriteLengthedBytesSlice(w io.Writer, version byte, m [][]byte) error
- func ZerologMarshalStack(err error) interface{}
- type BaseSemWorker
- func (wk *BaseSemWorker) Close()
- func (wk *BaseSemWorker) Done()
- func (wk *BaseSemWorker) Jobs() uint64
- func (wk *BaseSemWorker) LazyCancel(timeout time.Duration)
- func (wk *BaseSemWorker) NewJob(callback ContextWorkerCallback) error
- func (wk *BaseSemWorker) Wait() error
- func (wk *BaseSemWorker) WaitChan() chan error
- type BuildInfo
- type Byter
- type BytesToByter
- type ChecksumReader
- type ChecksumWriter
- type ContextDaemon
- type ContextKey
- type ContextTimer
- type ContextWorkerCallback
- type Daemon
- type DefaultJSONMarshaled
- type DistributeWorker
- type DummyByter
- type DummyChecksumReader
- type DummyChecksumWriter
- type DummyIsValider
- type ErrgroupWorker
- type Error
- func (er Error) Call() Error
- func (er Error) Error() string
- func (er Error) Errorf(s string, a ...interface{}) Error
- func (er Error) Format(st fmt.State, verb rune)
- func (er Error) Is(err error) bool
- func (er Error) StackTrace() errors.StackTrace
- func (er Error) Unwrap() error
- func (er Error) Wrap(err error) Error
- func (er Error) Wrapf(err error, s string, a ...interface{}) Error
- type FuncChain
- type GCache
- type GCacheObjectPool
- type GzipReader
- type GzipWriter
- type Hash
- type HashByter
- type HashChecksumReader
- type HashChecksumWriter
- type Hasher
- type IsValider
- type JSONMarshaled
- type JSONSetMarshaled
- type Locked
- func (l *Locked[T]) Empty(f func(_ T, isempty bool) error) error
- func (l *Locked[T]) EmptyValue() *Locked[T]
- func (l *Locked[T]) Get(create func() (T, error)) (v T, _ error)
- func (l *Locked[T]) Set(f func(_ T, isempty bool) (T, error)) (v T, _ error)
- func (l *Locked[T]) SetValue(v T) *Locked[T]
- func (l *Locked[T]) Value() (v T, isempty bool)
- type LockedMap
- type ObjectPool
- type ParallelWorker
- func (wk *ParallelWorker) Done()
- func (wk *ParallelWorker) Errors() <-chan error
- func (wk *ParallelWorker) FinishedJobs() int
- func (wk *ParallelWorker) IsFinished() bool
- func (wk *ParallelWorker) Jobs() uint
- func (wk *ParallelWorker) NewJob(j interface{})
- func (wk *ParallelWorker) Run(callback WorkerCallback) *ParallelWorker
- type ReadableJSONDuration
- type ShardedMap
- func (l *ShardedMap[K, V]) Close()
- func (l *ShardedMap[K, V]) Empty()
- func (l *ShardedMap[K, V]) Exists(k K) bool
- func (l *ShardedMap[K, V]) Get(k K, create func() (V, error)) (v V, found bool, _ error)
- func (l *ShardedMap[K, V]) Len() int
- func (l *ShardedMap[K, V]) Remove(k K, f func(V) error) (bool, error)
- func (l *ShardedMap[K, V]) RemoveValue(k K) bool
- func (l *ShardedMap[K, V]) Set(k K, f func(V, bool) (V, error)) (v V, _ error)
- func (l *ShardedMap[K, V]) SetValue(k K, v V) (found bool)
- func (l *ShardedMap[K, V]) Traverse(f func(K, V) bool)
- func (l *ShardedMap[K, V]) Value(k K) (v V, found bool)
- type SingleLockedMap
- func (l *SingleLockedMap[K, V]) Close()
- func (l *SingleLockedMap[K, V]) Empty()
- func (l *SingleLockedMap[K, V]) Exists(k K) bool
- func (l *SingleLockedMap[K, V]) Get(k K, create func() (V, error)) (v V, found bool, err error)
- func (l *SingleLockedMap[K, V]) Len() int
- func (l *SingleLockedMap[K, V]) Remove(k K, f func(V) error) (bool, error)
- func (l *SingleLockedMap[K, V]) RemoveValue(k K) bool
- func (l *SingleLockedMap[K, V]) Set(k K, f func(_ V, found bool) (V, error)) (V, error)
- func (l *SingleLockedMap[K, V]) SetValue(k K, v V) (found bool)
- func (l *SingleLockedMap[K, V]) Traverse(f func(K, V) bool)
- func (l *SingleLockedMap[K, V]) Value(k K) (v V, found bool)
- type StreamDecoder
- type StreamEncoder
- type Stringer
- type Timer
- type TimerID
- type Timers
- func (ts *Timers) IsTimerStarted(id TimerID) bool
- func (ts *Timers) ResetTimer(id TimerID) error
- func (ts *Timers) SetTimer(timer Timer) error
- func (ts *Timers) Start(context.Context) error
- func (ts *Timers) StartTimers(ids []TimerID, stopOthers bool) error
- func (ts *Timers) Started() []TimerID
- func (ts *Timers) Stop() error
- func (ts *Timers) StopTimers(ids []TimerID) error
- func (ts *Timers) StopTimersAll() error
- type ULIDPool
- type Version
- func (v Version) Compare(b Version) int
- func (v Version) IsCompatible(b Version) bool
- func (v Version) IsEmpty() bool
- func (v Version) IsValid([]byte) error
- func (v Version) Major() uint64
- func (v Version) MarshalText() ([]byte, error)
- func (v Version) Minor() uint64
- func (v Version) Patch() uint64
- func (v Version) Prerelease() string
- func (v Version) String() string
- func (v *Version) UnmarshalText(b []byte) error
- type WorkerCallback
Constants ¶
This section is empty.
Variables ¶
var ( ContextTimerPoolGet = func() *ContextTimer { return contextTimerPool.Get().(*ContextTimer) } ContextTimerPoolPut = func(ct *ContextTimer) { ct.Lock() ct.ContextDaemon = nil ct.id = TimerID("") ct.interval = nil ct.callback = nil ct.c = 0 ct.Unlock() contextTimerPool.Put(ct) } )
var ( ErrDaemonAlreadyStarted = NewError("daemon already started") ErrDaemonAlreadyStopped = NewError("daemon already stopped") )
var ( ErrFound = NewError("found") ErrNotFound = NewError("not found") ErrDuplicated = NewError("duplicated") ErrWrongType = NewError("wrong type") ErrNotImplemented = NewError("not implemented") ErrInternal = NewError("internal error") )
var ( ErrLockedSetIgnore = NewError("ignore to set locked value") ErrLockedMapClosed = NewError("locked map closed") )
var ErrInvalid = NewError("invalid")
var ErrStopTimer = NewError("stop timer")
var ErrWorkerContextCanceled = NewError("context canceled in worker")
var MinVersionLength = 2
var (
ULIDLen = len([]byte(ULID().String()))
)
Functions ¶
func BatchWork ¶
func BatchWork( ctx context.Context, size, limit uint64, pref func(_ context.Context, last uint64) error, f func(_ context.Context, i, last uint64) error, ) error
BatchWork runs f by limit size in worker. For example, size=5 limit=2 are given, 1. Run worker(0,1) 2. Run worker(2,3) 3. Run worker(4), done.
func BigBytesToInt64 ¶
func BytesToInt64 ¶
func BytesToUint64 ¶
func CheckIsValiderSlice ¶
func ConcatByterSlice ¶
func ConcatByters ¶
func ConcatBytesSlice ¶
func CountFilteredSlice ¶
func DecodeHash ¶
func EncodeHash ¶
func Filter2Slices ¶
func FilterMap ¶
func FilterMap[T any, Y comparable](s map[Y]T, f func(Y, T) bool) []T
func FilterSlice ¶
func Float64ToBytes ¶
func FuncCaller ¶
func InSlice ¶
func InSlice[T comparable](s []T, n T) int
func InSliceFunc ¶
func Int64ToBigBytes ¶
func Int64ToBytes ¶
func InterfaceSetValue ¶
func InterfaceSetValue(v, target interface{}) error
func IsDuplicatedSlice ¶
func IsValidURL ¶
func LoadFromContext ¶
func LoadFromContextOK ¶
func MarshalJSON ¶
func MarshalJSONIndent ¶
func MustMarshalJSON ¶
func MustMarshalJSON(i interface{}) []byte
func MustMarshalJSONIndent ¶
func MustMarshalJSONIndent(i interface{}) []byte
func MustMarshalJSONIndentString ¶
func MustMarshalJSONIndentString(i interface{}) string
func NormalizeTime ¶
NormalizeTime clear the nanoseconds part from Time and make time to UTC. "2009-11-10T23:00:00.00101010Z" -> "2009-11-10T23:00:00.001Z",
func ParseRFC3339 ¶
ParseRFC3339 parses RFC3339 string.
func ReadLengthedBytesSlice ¶
func RunDistributeWorker ¶
func RunErrgroupWorker ¶
func RunErrgroupWorkerByJobs ¶
func RunErrgroupWorkerByJobs(ctx context.Context, jobs ...ContextWorkerCallback) error
func SHA256Checksum ¶
func StringErrorFunc ¶
func TimeString ¶
func Uint64ToBigBytes ¶
func Uint64ToBytes ¶
func Uint8ToBytes ¶
func UintToBytes ¶
func UnmarshalJSON ¶
func WriteLengthedBytesSlice ¶
func ZerologMarshalStack ¶
func ZerologMarshalStack(err error) interface{}
Types ¶
type BaseSemWorker ¶
type BaseSemWorker struct { Ctx context.Context //nolint:containedctx //... Sem *semaphore.Weighted Cancel func() NewJobFunc func(context.Context, uint64, ContextWorkerCallback) N int64 JobCount uint64 // contains filtered or unexported fields }
func NewBaseSemWorker ¶
func NewBaseSemWorker(ctx context.Context, semsize int64) *BaseSemWorker
func (*BaseSemWorker) Close ¶
func (wk *BaseSemWorker) Close()
func (*BaseSemWorker) Done ¶
func (wk *BaseSemWorker) Done()
func (*BaseSemWorker) Jobs ¶
func (wk *BaseSemWorker) Jobs() uint64
func (*BaseSemWorker) LazyCancel ¶
func (wk *BaseSemWorker) LazyCancel(timeout time.Duration)
func (*BaseSemWorker) NewJob ¶
func (wk *BaseSemWorker) NewJob(callback ContextWorkerCallback) error
func (*BaseSemWorker) Wait ¶
func (wk *BaseSemWorker) Wait() error
func (*BaseSemWorker) WaitChan ¶
func (wk *BaseSemWorker) WaitChan() chan error
type BuildInfo ¶
func ParseBuildInfo ¶
type BytesToByter ¶
type BytesToByter []byte
func (BytesToByter) Bytes ¶
func (b BytesToByter) Bytes() []byte
type ChecksumReader ¶
type ChecksumReader interface { io.ReadCloser Checksum() string }
type ChecksumWriter ¶
type ChecksumWriter interface { io.WriteCloser Name() string Checksum() string }
type ContextDaemon ¶
func NewContextDaemon ¶
func NewContextDaemon(startfunc func(context.Context) error) *ContextDaemon
func (*ContextDaemon) IsStarted ¶
func (dm *ContextDaemon) IsStarted() bool
func (*ContextDaemon) Stop ¶
func (dm *ContextDaemon) Stop() error
type ContextKey ¶
type ContextKey string
type ContextTimer ¶
type ContextTimer struct { *ContextDaemon *logging.Logging sync.RWMutex // contains filtered or unexported fields }
func NewContextTimer ¶
func (*ContextTimer) ID ¶
func (ct *ContextTimer) ID() TimerID
func (*ContextTimer) Reset ¶
func (ct *ContextTimer) Reset() error
func (*ContextTimer) SetInterval ¶
func (*ContextTimer) Stop ¶
func (ct *ContextTimer) Stop() error
type ContextWorkerCallback ¶
type DefaultJSONMarshaled ¶
type DefaultJSONMarshaled struct {
// contains filtered or unexported fields
}
func (DefaultJSONMarshaled) Marshaled ¶
func (m DefaultJSONMarshaled) Marshaled() ([]byte, bool)
func (*DefaultJSONMarshaled) SetMarshaled ¶
func (m *DefaultJSONMarshaled) SetMarshaled(b []byte)
type DistributeWorker ¶
type DistributeWorker struct { *BaseSemWorker // contains filtered or unexported fields }
func NewDistributeWorker ¶
func NewDistributeWorker(ctx context.Context, semsize int64, errch chan error) *DistributeWorker
func (*DistributeWorker) Close ¶
func (wk *DistributeWorker) Close()
type DummyByter ¶
type DummyByter func() []byte
func (DummyByter) Bytes ¶
func (d DummyByter) Bytes() []byte
type DummyChecksumReader ¶
type DummyChecksumReader struct { io.ReadCloser // contains filtered or unexported fields }
func NewDummyChecksumReader ¶
func NewDummyChecksumReader(f io.ReadCloser, cr ChecksumReader) *DummyChecksumReader
func (*DummyChecksumReader) Checksum ¶
func (r *DummyChecksumReader) Checksum() string
type DummyChecksumWriter ¶
type DummyChecksumWriter struct { io.WriteCloser // contains filtered or unexported fields }
func NewDummyChecksumWriter ¶
func NewDummyChecksumWriter(f io.WriteCloser, cw ChecksumWriter) *DummyChecksumWriter
func (*DummyChecksumWriter) Checksum ¶
func (w *DummyChecksumWriter) Checksum() string
func (*DummyChecksumWriter) Name ¶
func (w *DummyChecksumWriter) Name() string
type DummyIsValider ¶
func (DummyIsValider) IsValid ¶
func (iv DummyIsValider) IsValid(b []byte) error
type ErrgroupWorker ¶
type ErrgroupWorker struct { *BaseSemWorker // contains filtered or unexported fields }
func NewErrgroupWorker ¶
func NewErrgroupWorker(ctx context.Context, semsize int64) *ErrgroupWorker
func (*ErrgroupWorker) Close ¶
func (wk *ErrgroupWorker) Close()
func (*ErrgroupWorker) RunChan ¶
func (wk *ErrgroupWorker) RunChan() chan error
func (*ErrgroupWorker) Wait ¶
func (wk *ErrgroupWorker) Wait() error
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
func (Error) StackTrace ¶
func (er Error) StackTrace() errors.StackTrace
type FuncChain ¶
type FuncChain struct {
// contains filtered or unexported fields
}
func NewFuncChain ¶
func NewFuncChain() *FuncChain
type GCache ¶
type GCache[K constraints.Ordered, V any] struct { // contains filtered or unexported fields }
func NewLFUGCache ¶
func NewLFUGCache[K constraints.Ordered, V any](_ K, _ V, size int) *GCache[K, V]
func NewLRUGCache ¶
func NewLRUGCache[K constraints.Ordered, V any](_ K, _ V, size int) *GCache[K, V]
type GCacheObjectPool ¶
type GCacheObjectPool struct {
// contains filtered or unexported fields
}
func NewGCacheObjectPool ¶
func NewGCacheObjectPool(size int) *GCacheObjectPool
func (*GCacheObjectPool) Close ¶
func (po *GCacheObjectPool) Close()
func (*GCacheObjectPool) Exists ¶
func (po *GCacheObjectPool) Exists(key string) bool
func (*GCacheObjectPool) Get ¶
func (po *GCacheObjectPool) Get(key string) (interface{}, bool)
type GzipReader ¶
GzipReader closes the underlying reader too.
func NewGzipReader ¶
func NewGzipReader(f io.Reader) (*GzipReader, error)
func (*GzipReader) Close ¶
func (r *GzipReader) Close() error
type GzipWriter ¶
GzipWriter closes the underlying reader too.
func NewGzipWriter ¶
func NewGzipWriter(f io.Writer) *GzipWriter
func (*GzipWriter) Close ¶
func (w *GzipWriter) Close() error
type HashByter ¶
type HashByter interface { // HashBytes is uses to generate hash HashBytes() []byte }
type HashChecksumReader ¶
func NewHashChecksumReader ¶
func NewHashChecksumReader(r io.ReadCloser, h hash.Hash) *HashChecksumReader
func (*HashChecksumReader) Checksum ¶
func (r *HashChecksumReader) Checksum() string
func (*HashChecksumReader) Close ¶
func (r *HashChecksumReader) Close() error
type HashChecksumWriter ¶
func NewHashChecksumWriter ¶
func NewHashChecksumWriter(fname string, w io.WriteCloser, h hash.Hash) *HashChecksumWriter
func (*HashChecksumWriter) Checksum ¶
func (w *HashChecksumWriter) Checksum() string
func (*HashChecksumWriter) Close ¶
func (w *HashChecksumWriter) Close() error
func (*HashChecksumWriter) Name ¶
func (w *HashChecksumWriter) Name() string
type JSONMarshaled ¶
type JSONSetMarshaled ¶
type JSONSetMarshaled interface {
SetMarshaled([]byte)
}
type LockedMap ¶
type LockedMap[K lockedMapKeys, V any] interface { Exists(key K) (found bool) Value(key K) (value V, found bool) SetValue(key K, value V) (found bool) RemoveValue(key K) (removed bool) Get(key K, create func() (value V, _ error)) (value V, found bool, _ error) Set(key K, f func(_ V, found bool) (value V, _ error)) (value V, _ error) Remove(key K, f func(value V) error) (removed bool, _ error) Traverse(f func(key K, value V) (keep bool)) Len() int Empty() Close() }
type ObjectPool ¶
type ParallelWorker ¶
func NewParallelWorker ¶
func NewParallelWorker(bufsize uint) *ParallelWorker
func (*ParallelWorker) Done ¶
func (wk *ParallelWorker) Done()
func (*ParallelWorker) Errors ¶
func (wk *ParallelWorker) Errors() <-chan error
func (*ParallelWorker) FinishedJobs ¶
func (wk *ParallelWorker) FinishedJobs() int
func (*ParallelWorker) IsFinished ¶
func (wk *ParallelWorker) IsFinished() bool
func (*ParallelWorker) Jobs ¶
func (wk *ParallelWorker) Jobs() uint
func (*ParallelWorker) NewJob ¶
func (wk *ParallelWorker) NewJob(j interface{})
func (*ParallelWorker) Run ¶
func (wk *ParallelWorker) Run(callback WorkerCallback) *ParallelWorker
type ReadableJSONDuration ¶
func (ReadableJSONDuration) MarshalText ¶
func (d ReadableJSONDuration) MarshalText() ([]byte, error)
func (*ReadableJSONDuration) UnmarshalJSON ¶
func (d *ReadableJSONDuration) UnmarshalJSON(b []byte) error
type ShardedMap ¶
type ShardedMap[K lockedMapKeys, V any] struct { sync.RWMutex // contains filtered or unexported fields }
func NewShardedMap ¶
func NewShardedMap[K lockedMapKeys, V any](_ K, _ V, size int64) (*ShardedMap[K, V], error)
func (*ShardedMap[K, V]) Close ¶
func (l *ShardedMap[K, V]) Close()
func (*ShardedMap[K, V]) Empty ¶
func (l *ShardedMap[K, V]) Empty()
func (*ShardedMap[K, V]) Exists ¶
func (l *ShardedMap[K, V]) Exists(k K) bool
func (*ShardedMap[K, V]) Get ¶
func (l *ShardedMap[K, V]) Get(k K, create func() (V, error)) (v V, found bool, _ error)
func (*ShardedMap[K, V]) Len ¶
func (l *ShardedMap[K, V]) Len() int
func (*ShardedMap[K, V]) Remove ¶
func (l *ShardedMap[K, V]) Remove(k K, f func(V) error) (bool, error)
func (*ShardedMap[K, V]) RemoveValue ¶
func (l *ShardedMap[K, V]) RemoveValue(k K) bool
func (*ShardedMap[K, V]) Set ¶
func (l *ShardedMap[K, V]) Set(k K, f func(V, bool) (V, error)) (v V, _ error)
func (*ShardedMap[K, V]) SetValue ¶
func (l *ShardedMap[K, V]) SetValue(k K, v V) (found bool)
func (*ShardedMap[K, V]) Traverse ¶
func (l *ShardedMap[K, V]) Traverse(f func(K, V) bool)
func (*ShardedMap[K, V]) Value ¶
func (l *ShardedMap[K, V]) Value(k K) (v V, found bool)
type SingleLockedMap ¶
type SingleLockedMap[K lockedMapKeys, V any] struct { sync.RWMutex // contains filtered or unexported fields }
func NewSingleLockedMap ¶
func NewSingleLockedMap[K lockedMapKeys, V any](K, V) *SingleLockedMap[K, V]
func (*SingleLockedMap[K, V]) Close ¶
func (l *SingleLockedMap[K, V]) Close()
func (*SingleLockedMap[K, V]) Empty ¶
func (l *SingleLockedMap[K, V]) Empty()
func (*SingleLockedMap[K, V]) Exists ¶
func (l *SingleLockedMap[K, V]) Exists(k K) bool
func (*SingleLockedMap[K, V]) Get ¶
func (l *SingleLockedMap[K, V]) Get(k K, create func() (V, error)) (v V, found bool, err error)
func (*SingleLockedMap[K, V]) Len ¶
func (l *SingleLockedMap[K, V]) Len() int
func (*SingleLockedMap[K, V]) Remove ¶
func (l *SingleLockedMap[K, V]) Remove(k K, f func(V) error) (bool, error)
func (*SingleLockedMap[K, V]) RemoveValue ¶
func (l *SingleLockedMap[K, V]) RemoveValue(k K) bool
func (*SingleLockedMap[K, V]) Set ¶
func (l *SingleLockedMap[K, V]) Set(k K, f func(_ V, found bool) (V, error)) (V, error)
func (*SingleLockedMap[K, V]) SetValue ¶
func (l *SingleLockedMap[K, V]) SetValue(k K, v V) (found bool)
func (*SingleLockedMap[K, V]) Traverse ¶
func (l *SingleLockedMap[K, V]) Traverse(f func(K, V) bool)
func (*SingleLockedMap[K, V]) Value ¶
func (l *SingleLockedMap[K, V]) Value(k K) (v V, found bool)
type StreamDecoder ¶
type StreamDecoder interface {
Decode(interface{}) error
}
func NewJSONStreamDecoder ¶
func NewJSONStreamDecoder(r io.Reader) StreamDecoder
type StreamEncoder ¶
type StreamEncoder interface {
Encode(interface{}) error
}
func NewJSONStreamEncoder ¶
func NewJSONStreamEncoder(w io.Writer) StreamEncoder
type Timers ¶
Timers handles the multiple timers and controls them selectively.
func (*Timers) IsTimerStarted ¶
func (*Timers) ResetTimer ¶
func (*Timers) StartTimers ¶
StartTimers starts timers with the given ids, before starting timers, stops the other timers if stopOthers is true.
func (*Timers) StopTimers ¶
func (*Timers) StopTimersAll ¶
type ULIDPool ¶
func NewULIDPool ¶
func NewULIDPool() *ULIDPool
type Version ¶
type Version struct {
// contains filtered or unexported fields
}
func EnsureParseVersion ¶
EnsureParseVersion tries to parse version string, but skips to check IsValid().
func MustNewVersion ¶
func ParseVersion ¶
ParseVersion tries to parse version string and also checks IsValid().
func (Version) IsCompatible ¶
IsCompatible checks if the given version is compatible to the target. The compatible conditions are major matches.
func (Version) MarshalText ¶
func (Version) Prerelease ¶
func (*Version) UnmarshalText ¶
type WorkerCallback ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package encoder supports to encode and decode structs in multiple formats.
|
Package encoder supports to encode and decode structs in multiple formats. |
json
Package jsonenc support encoding and decoding by json.
|
Package jsonenc support encoding and decoding by json. |
Package fixedtree provides tree structures.
|
Package fixedtree provides tree structures. |
Package hint provides to handle structs and data with type and it's version.
|
Package hint provides to handle structs and data with type and it's version. |
Package localtime provides time related funcs.
|
Package localtime provides time related funcs. |
Package logging supports the consistent logging for modules.
|
Package logging supports the consistent logging for modules. |
Package ps is processes
|
Package ps is processes |
Package valuehash provides valuehashes.
|
Package valuehash provides valuehashes. |