Documentation
¶
Index ¶
- Variables
- func Any(flags ...bool) bool
- func AnyToStruct[T any](data any) (*T, error)
- func CmpFloat(x, y any) int
- func CmpInt(x, y any) int
- func CmpNil(x, y any) int
- func CmpString(x, y any) int
- func CmpTime(x, y any) int
- func CmpUUID(x, y any) int
- func ConvertToFloat(value any, targetType reflect.Type) (any, error)
- func ConvertToInt(value any, targetType reflect.Type) (any, error)
- func ConvertToString(value any, targetType reflect.Type) (any, error)
- func ConvertToTime(value any, targetType reflect.Type) (any, error)
- func ConvertToUUID(value any, targetType reflect.Type) (any, error)
- func CtxClosed(ctx context.Context) bool
- func Filter[T any](arr []T, f func(T) bool) []T
- func GetIndicesInOrder[T comparable](original []T, ordered []T) []int
- func GetKey(prefix, name string) string
- func MakeSet[T comparable, V any](m1 map[T]V) map[T]struct{}
- func NewIncorrectErrIndexError() error
- func ShiftElementsToEnd[T any, K comparable](source []T, orderedShiftedIDs []K, getElemID func(T) K) []T
- func SortSlice(slice []any, comparator CmpFunc)
- func Trim(str, prefix, suffix string) string
- func WalkWithFilter(dir string, filterFunc func(entry os.DirEntry) bool) ([]string, error)
- type CmpFunc
- type ContextCancelError
- type IncorrectErrIndexError
- type Job
- type Syncer
- type WorkerPool
- type WorkerSyncer
Constants ¶
This section is empty.
Variables ¶
var ErrDirNotExists = errors.New("directory doesn't exist")
Functions ¶
func AnyToStruct ¶
AnyToStruct converts map or struct to selected struct.
func GetIndicesInOrder ¶
func GetIndicesInOrder[T comparable](original []T, ordered []T) []int
GetIndicesInOrder returns an array of indexes of the elements from the "original" in the order of the elements from the "ordered".
func MakeSet ¶
func MakeSet[T comparable, V any](m1 map[T]V) map[T]struct{}
MakeSet creates new set as map without values.
func NewIncorrectErrIndexError ¶
func NewIncorrectErrIndexError() error
func ShiftElementsToEnd ¶
func ShiftElementsToEnd[T any, K comparable](source []T, orderedShiftedIDs []K, getElemID func(T) K) []T
ShiftElementsToEnd moves all items with ids equal to orderedShiftedIds to the end in the same order. if T is a reference type (struct pointer, interface, ...), then the final slice will contain the original objects.
func SortSlice ¶
SortSlice sorts slice of any, where slice elements can be nil, int, float64, string or time.Time.
Types ¶
type ContextCancelError ¶
type ContextCancelError struct{}
func (*ContextCancelError) Error ¶
func (e *ContextCancelError) Error() string
type IncorrectErrIndexError ¶
type IncorrectErrIndexError struct{}
func (*IncorrectErrIndexError) Error ¶
func (e *IncorrectErrIndexError) Error() string
type Syncer ¶
type Syncer struct {
// contains filtered or unexported fields
}
func (*Syncer) WorkerSyncer ¶
func (s *Syncer) WorkerSyncer() *WorkerSyncer
type WorkerPool ¶
type WorkerPool struct {
// contains filtered or unexported fields
}
WorkerPool represents a pool of goroutines that can execute any function with arguments.
func NewWorkerPool ¶
func NewWorkerPool(fn any, errIdx, workerCount int) *WorkerPool
NewWorkerPool creates a new WorkerPool with the specified number of workers.
func (*WorkerPool) Add ¶
func (wp *WorkerPool) Add(delta int32)
func (*WorkerPool) Done ¶
func (wp *WorkerPool) Done()
func (*WorkerPool) Start ¶
func (wp *WorkerPool) Start()
Start initializes the worker pool and starts processing jobs.
func (*WorkerPool) Stop ¶
func (wp *WorkerPool) Stop()
Stop waits for all workers to finish and closes the Job channel.
func (*WorkerPool) Submit ¶
func (wp *WorkerPool) Submit(args ...any)
Submit adds a new Job to the pool.
func (*WorkerPool) WaitOrError ¶
func (wp *WorkerPool) WaitOrError() error
WaitOrError waits for all workers or first error.
type WorkerSyncer ¶
type WorkerSyncer struct {
// contains filtered or unexported fields
}
func (*WorkerSyncer) Done ¶
func (s *WorkerSyncer) Done(ctx context.Context)
func (*WorkerSyncer) WaitPrevious ¶
func (s *WorkerSyncer) WaitPrevious(ctx context.Context)