cube

package module
v0.0.0-...-9f10b00 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: Unlicense Imports: 26 Imported by: 0

README

cube

All my golang pkgs.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTaskPoolQueueFull = errors.New("rrscpkgs.taskpool: queue full")
	ErrTaskPoolClosed    = errors.New("rrscpkgs.taskpool: closed")
)
View Source
var (
	ErrJsonStreamBadElement = errors.New("json stream: bad element, required '{'")
)

Functions

func Abs

func Abs[T Numeric](x T) T

func AllNamedEnums

func AllNamedEnums[T IEnum](min T, max T) []T

func ExecAllDeathHooks

func ExecAllDeathHooks()

func FillEnum

func FillEnum[T IEnum](sp *[]T, min T, max T)

func Fly

func Fly(fnc func())

func FuncName

func FuncName(act any) string

func GetFreePort

func GetFreePort() (int, error)

func IsDeathing

func IsDeathing() bool

func JsonStreamZeroCopy

func JsonStreamZeroCopy(fp string) (iter.Seq2[json.RawMessage, error], error)

func MarshalJSON

func MarshalJSON(val any) ([]byte, error)

func MarshalJSONString

func MarshalJSONString(val any) (string, error)

func Must

func Must[T any](val T, err error) T

func MustJsonMarshalIndent

func MustJsonMarshalIndent(v any) []byte

func MustJsonMarshalIndentString

func MustJsonMarshalIndentString(v any) string

func MustJsonMarshalString

func MustJsonMarshalString(v any) string

func MustMarshalJSON

func MustMarshalJSON(v any) []byte

func OnDeath

func OnDeath(fn func(wg *sync.WaitGroup))

func Peek

func Peek[T IJsonValue](mapv map[string]any, keys ...string) (T, bool)

func RandAsciiBytes

func RandAsciiBytes(length int) []byte

func RandBytes

func RandBytes(pool []byte, length int) []byte

func RandLowerAsciiBytes

func RandLowerAsciiBytes(length int) []byte

func ReadDirStream

func ReadDirStream(dir string) (iter.Seq2[os.FileInfo, error], error)

func ReadStack

func ReadStack(skip int, size int) string

func UnmarshalJSON

func UnmarshalJSON(bytes []byte, dest any) error

func UnmarshalJSONString

func UnmarshalJSONString(txt string, dest any) error

func WalkStream

func WalkStream(root string, opts *WalkOptions) (iter.Seq2[*FileInfoWithDir, error], error)

Types

type FileInfoWithDir

type FileInfoWithDir struct {
	os.FileInfo
	Dir string
}

func (*FileInfoWithDir) Fullpath

func (fi *FileInfoWithDir) Fullpath() string

func (*FileInfoWithDir) String

func (fi *FileInfoWithDir) String() string

type IEnum

type IEnum interface {
	IntType
	fmt.Stringer
}

type IJsonValue

type IJsonValue interface {
	~int64 | ~bool | ~string | ~float64
}

type ITaskItem

type ITaskItem interface {
	Exec(ctx context.Context)
}

type IntType

type IntType interface {
	SingedInt | UnsignedInt
}

type Numeric

type Numeric interface {
	constraints.Signed | constraints.Float
}

type Set

type Set[T comparable] map[T]struct{}

func (Set[T]) Add

func (s Set[T]) Add(v T)

func (Set[T]) Clear

func (s Set[T]) Clear() Set[T]

func (Set[T]) Del

func (s Set[T]) Del(v T)

func (Set[T]) Has

func (s Set[T]) Has(v T) bool

func (Set[T]) Len

func (s Set[T]) Len() int

type SingedInt

type SingedInt interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type TaskFuncType

type TaskFuncType func(ctx context.Context)

func (TaskFuncType) Exec

func (t TaskFuncType) Exec(ctx context.Context)

type TaskPool

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

func NewTaskPool

func NewTaskPool(opts *TaskPoolOptions) *TaskPool

func (*TaskPool) Add

func (pool *TaskPool) Add(task ITaskItem) (err error)

func (*TaskPool) AddFunc

func (pool *TaskPool) AddFunc(f func(ctx context.Context)) error

func (*TaskPool) Close

func (pool *TaskPool) Close(wait bool)

func (*TaskPool) Wait

func (pool *TaskPool) Wait()

type TaskPoolOptions

type TaskPoolOptions struct {
	Context      context.Context
	OnPanic      func(ctx context.Context, item ITaskItem, err any)
	Workers      int
	MaxQueueSize int
}

type UnsignedInt

type UnsignedInt interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64
}

type WalkOptions

type WalkOptions struct {
	MaxDepth       int
	MatchPatterns  []string
	IgnorePatterns []string
	OnlyTestName   bool
	FollowLink     bool
	OnSlightError  func(error)
}

Directories

Path Synopsis
test/main command
x

Jump to

Keyboard shortcuts

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