relec

package module
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: Apache-2.0 Imports: 15 Imported by: 2

README

relec

Go Utilities to be used in your project

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Absolute

func Absolute[T int | int8 | int16 | int32 | int64 | float32 | float64](value T) T

func ArrayContains

func ArrayContains[T ~string | int | int8 | int16 | int32 | int64 | float32 | float64](set []T, value T) bool

func CheckIfFilesExists

func CheckIfFilesExists(files ...string) error

func Concurrent

func Concurrent[T any](ctx context.Context, array []T, concurrency int, execute func(ctx context.Context, one T, executionNumber int) error) error

func ConcurrentC added in v0.0.2

func ConcurrentC[T any](ctx context.Context, next *Next[T], concurrency int, execute func(ctx context.Context, one T, sequence int64) error) error

func ConcurrentF added in v0.0.15

func ConcurrentF(ctx context.Context, functions ...CtxFunc) error

func ConcurrentInGroup added in v0.0.17

func ConcurrentInGroup[T any](group *CxGroup, array []T, execute func(ctx context.Context, one T) error)

func FindInArray

func FindInArray[T any](set []T, match func(elem T) bool) (int, bool)

func IsInstance

func IsInstance(val any, typ reflect.Kind) bool

func IsOfType

func IsOfType(object interface{}, decidingKey string) (bool, error)

func IsSubset

func IsSubset[T comparable](setArray, subsetArray []T) bool

func MaxDate

func MaxDate(v1, v2 time.Time) time.Time

func Unmarshal

func Unmarshal(from interface{}, object interface{}) error

Unmarshal serializes and deserializes any from into the object return error if occurred

func UnmarshalFile

func UnmarshalFile(file string, dest any) error

func Validate

func Validate[T any](structure T) error

Types

type CtxFunc added in v0.0.15

type CtxFunc = func(ctx context.Context) error

type CxGroup added in v0.0.16

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

func NewCGroup added in v0.0.16

func NewCGroup(ctx context.Context) *CxGroup

func NewCGroupWithLimit added in v0.0.16

func NewCGroupWithLimit(ctx context.Context, limit int) *CxGroup

func (*CxGroup) Add added in v0.0.16

func (g *CxGroup) Add(execute func(ctx context.Context) error)

func (*CxGroup) Block added in v0.0.16

func (g *CxGroup) Block() error

type Hashable added in v0.0.5

type Hashable interface {
	Hash() string
}

type Identifier added in v0.0.5

type Identifier interface {
	ID() string
}

type Logger

type Logger interface {
	Info(v ...interface{})
	Infof(format string, v ...interface{})
	Debug(v ...interface{})
	Debugf(format string, v ...interface{})
	Error(v ...interface{})
	Fatal(v ...interface{})
	Fatalf(format string, v ...interface{})
	Errorf(format string, v ...interface{})
	Warn(v ...interface{})
	Warnf(format string, v ...interface{})
}

type Next added in v0.0.16

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

func Yield added in v0.0.2

func Yield[T any](next func(prev T) (bool, T, error)) *Next[T]

func (*Next[T]) Close added in v0.0.16

func (n *Next[T]) Close()

func (*Next[T]) Next added in v0.0.16

func (n *Next[T]) Next() bool

type Set added in v0.0.5

type Set[T comparable] struct {
	// contains filtered or unexported fields
}

func NewSet added in v0.0.5

func NewSet[T comparable](initial ...T) *Set[T]

Create a new set

func (*Set[T]) Array added in v0.0.5

func (this *Set[T]) Array() []T

func (*Set[T]) Difference added in v0.0.5

func (this *Set[T]) Difference(set *Set[T]) *Set[T]

Find the difference between two sets

func (*Set[T]) Exists added in v0.0.5

func (this *Set[T]) Exists(element T) bool

Test to see whether or not the element is in the set

func (*Set[T]) Hash added in v0.0.5

func (this *Set[T]) Hash(elem T) string

func (*Set[T]) Insert added in v0.0.5

func (this *Set[T]) Insert(element T)

Add an element to the set

func (*Set[T]) Intersection added in v0.0.5

func (this *Set[T]) Intersection(set *Set[T]) *Set[T]

Find the intersection of two sets

func (*Set[T]) Len added in v0.0.5

func (this *Set[T]) Len() int

Return the number of items in the set

func (*Set[T]) MarshalJSON added in v0.0.5

func (this *Set[T]) MarshalJSON() ([]byte, error)

func (*Set[T]) ProperSubsetOf added in v0.0.5

func (this *Set[T]) ProperSubsetOf(set *Set[T]) bool

Test whether or not this set is a proper subset of "set"

func (*Set[T]) Range added in v0.0.5

func (this *Set[T]) Range(f func(T))

Call f for each item in the set

func (*Set[T]) Remove added in v0.0.5

func (this *Set[T]) Remove(element T)

Remove an element from the set

func (*Set[T]) String added in v0.0.5

func (this *Set[T]) String() string

func (*Set[T]) SubsetOf added in v0.0.5

func (this *Set[T]) SubsetOf(set *Set[T]) bool

Test whether or not this set is a subset of "set"

func (*Set[T]) Union added in v0.0.5

func (this *Set[T]) Union(set *Set[T]) *Set[T]

Find the union of two sets

func (*Set[T]) UnmarshalJSON added in v0.0.5

func (this *Set[T]) UnmarshalJSON(data []byte) error

func (*Set[T]) WithHasher added in v0.0.5

func (this *Set[T]) WithHasher(f func(T) string) *Set[T]

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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