Documentation ¶
Index ¶
- Constants
- Variables
- func Assert(cond bool)
- func AssertCustomError(cond bool, err error)
- func AssertThat() assertThat
- func AssertThatTyped[T any]() assertThatTyped[T]
- func AssertThatTyped2[T1 any, T2 any]() assertThatTyped2[T1, T2]
- func AssertThatTyped3[T1 any, T2 any, T3 any]() assertThatTyped3[T1, T2, T3]
- func AssertThatTyped4[T1 any, T2 any, T3 any, T4 any]() assertThatTyped4[T1, T2, T3, T4]
- func AssertThatTyped5[T1 any, T2 any, T3 any, T4 any, T5 any]() assertThatTyped5[T1, T2, T3, T4, T5]
- func CheckErr(possibleError any) bool
- func ComplexNonInclusiveRange(start int, end int, step int) []int
- func ComplexRange(start int, end int, step int) []int
- func ConvertToAnyArray[T any](array []T) []any
- func Dump(vs ...any)
- func EnsureType[T any](value any) T
- func EnsureTypeBool[T any](value any) bool
- func ExecuteAndPassthrough(f func([]any) []any, values ...any) []any
- func ExecuteInDebugMode(f func())
- func ExpandError(err error) error
- func Explode(array []any, values ...*any)
- func ExplodeTyped[T any](array []T, values ...*T)
- func GetDebugMode() bool
- func GetMaxForType[T NumericType]() T
- func GetMinForType[T NumericType]() T
- func IKnowThatThisPackageIsNotUsed(x ...any)
- func IKnowThatThisVariableIsNotUsed(x ...any)
- func IsError(err error) bool
- func IsErrorEqual(err1 error, err2 error) bool
- func MakeGenerator[T any](abortChannel <-chan struct{}, generatorFunc func(chan T) bool) <-chan T
- func MakeUnit[T any](unitName string) func(T) UnitValue[T]
- func NewError(msg string) error
- func NormalizeUnit[T any](unitName string) func(any) Result[UnitValue[T]]
- func NotImplemented()
- func NotSupported()
- func NullValue[T any]() T
- func PackToArray(values ...any) []any
- func PackagesUsedInDebugging(x ...any)
- func PanicIfError(err error)
- func PanicIfErrorFromOutput(returns ...any)
- func Pipe(initialArgument any, functions ...any) any
- func PipeTyped[VT any](initialArgument VT, functions ...func(VT) VT) VT
- func PipeTypedArgReturn[IAT any, RT any](initialArgument IAT, functions ...any) RT
- func PipeTypedReturn[RT any](initialArgument any, functions ...any) RT
- func PossiblyUsingThis(x ...any)
- func PromiseAll(functions ...any) ([]any, []error)
- func Range(end int) []int
- func RangeNonInclusive(end int) []int
- func SetDebugMode(mode bool)
- func StartEndNonInclusiveRange(start int, end int) []int
- func StartEndRange(start int, end int) []int
- func Ternary[V any](condition bool, ifTrue V, ifFalse V) V
- func TernaryNull[V any](value V, ifNullValue V) V
- func TernaryNullable[V any](value Nullable[V], ifNullValue V) V
- func TernaryResult[V any](result Result[V], ifOk V, ifErr V) V
- func ToPtr[T any](value T) *T
- func Unreachable()
- func WithContext[T any](ctx ContextManagerInterface, f func(ctx ContextManagerInterface) T) T
- func WithGoContext[T any](ctx GoContextManagerInterface, f func(ctx GoContextManagerInterface) T) T
- func Yield[T any](ch chan<- T, value T)
- type AnyFloat
- type AnyInt
- type AssertableBoolInterface
- type AssertableInterface
- type BroadcastChannel
- type ContextManagerInterface
- type DefaultableInterface
- type EnsuredObject
- type ErrorableGenericResultInterface
- type Exception
- type ExceptionCategory
- type ExtendedException
- type ExtendedUnwrappableInterface
- type FeatureFlags
- func (f FeatureFlags) Dev() Result[string]
- func (f *FeatureFlags) GetAnyFlag(key string) any
- func (f *FeatureFlags) GetBoolFlag(key string) bool
- func (f *FeatureFlags) GetDefault() *FeatureFlags
- func (f *FeatureFlags) GetFloatFlag(key string) float64
- func (f *FeatureFlags) GetIntFlag(key string) int64
- func (f *FeatureFlags) GetStringFlag(key string) string
- func (f *FeatureFlags) GetUintFlag(key string) uint64
- func (f *FeatureFlags) SetAnyFlag(key string, value any)
- func (f *FeatureFlags) SetBoolFlag(key string, value bool)
- func (f *FeatureFlags) SetFloatFlag(key string, value float64)
- func (f *FeatureFlags) SetIntFlag(key string, value int64)
- func (f *FeatureFlags) SetStringFlag(key string, value string)
- func (f *FeatureFlags) SetUintFlag(key string, value uint64)
- type GoContextManagerInterface
- type GuardedObjectInterface
- type Nullable
- func (n Nullable[T]) AndThen(fn func(T) any) any
- func (n Nullable[T]) Equal(other Nullable[T]) bool
- func (n Nullable[T]) ExactEqual(other Nullable[T]) bool
- func (n Nullable[T]) Expect(err any)
- func (n Nullable[T]) ExpectErr(err any)
- func (n Nullable[T]) GetError() error
- func (n Nullable[T]) GoString() string
- func (n Nullable[T]) IsError() bool
- func (n Nullable[T]) IsZero() bool
- func (n Nullable[T]) String() string
- func (n Nullable[T]) Unwrap() T
- func (n Nullable[T]) UnwrapAsResultOrErr(f func(Nullable[T])) Result[T]
- func (n Nullable[T]) UnwrapErr() error
- func (n Nullable[T]) UnwrapOr(defaultVal T) T
- func (n Nullable[T]) UnwrapOrErr(f func(Nullable[T])) T
- func (n Nullable[T]) UnwrapWithErr() (T, error)
- func (n Nullable[T]) Value() (driver.Value, error)
- func (n Nullable[T]) ValueOrZero() T
- type NumericType
- type Observable
- type Pipeline
- func (p *Pipeline) Call(args ...any) *Pipeline
- func (p *Pipeline) Catch(f any) *Pipeline
- func (p *Pipeline) Evaluate(args ...any) *Pipeline
- func (p *Pipeline) EvaluateOnData() *Pipeline
- func (p *Pipeline) Finally(f any) *Pipeline
- func (p *Pipeline) GetError() error
- func (p *Pipeline) GetErrorSpecial() error
- func (p *Pipeline) IsError() bool
- func (p *Pipeline) Run(args ...any) []any
- func (p *Pipeline) Then(f any) *Pipeline
- func (p *Pipeline) Value() []any
- func (p *Pipeline) ValueRef(returns ...*any)
- type PipelineArray
- type PipelineArrayAnyError
- type Promise
- type Result
- func CheckAllResults[T any](results ...Result[T]) Result[T]
- func ConvertToResult[T any](value T, err error) Result[T]
- func ConvertToResultMultiple(args ...any) Result[any]
- func EnsureObjectImplementsInterface[OT any, IT any](self OT) Result[string]
- func EnsureTypeResult[T any](value any) Result[T]
- func Err[T any](err error) Result[T]
- func ErrWithValue[T any](value T, err error) Result[T]
- func MakeErrorResult[T any](err error) Result[T]
- func MakeErrorResultWithValue[T any](value T, err error) Result[T]
- func MakeOkResult[T any](value T) Result[T]
- func MakeResult[T any]() Result[T]
- func Ok[T any](value T) Result[T]
- func PanicToError[T any](f func() T) Result[T]
- func (r Result[T]) AndThen(fn func(T) any) any
- func (r *Result[T]) Error(err error) Result[T]
- func (r Result[T]) Expect(err any)
- func (r Result[T]) ExpectErr(err any)
- func (r Result[T]) GetError() error
- func (r Result[T]) GoString() string
- func (r Result[T]) IsError() bool
- func (r *Result[T]) Ok(value T) Result[T]
- func (r Result[T]) String() string
- func (r Result[T]) ToPointer() *Result[T]
- func (r *Result[T]) ToResult() Result[T]
- func (r Result[T]) Unwrap() T
- func (r Result[T]) UnwrapAsResultOrErr(f func(Result[T])) Result[T]
- func (r Result[T]) UnwrapErr() error
- func (r Result[T]) UnwrapOr(defaultVal T) T
- func (r Result[T]) UnwrapOrErr(f func(Result[T])) T
- func (r Result[T]) UnwrapWithErr() (T, error)
- type SubCategoryExtendedException
- type SwitchResult
- type ThreadSafeObject
- type Transaction
- type Tuple2
- type Tuple3
- type Tuple4
- type Tuple5
- type Union
- type UnionInterface
- type UnionTypeConstraint
- type UnitValue
- type UnwrappableInterface
Constants ¶
const (
ENSURE_OBJECT_OK_STATE = "OK"
)
Variables ¶
var UnitInvalidTypeError = NewError("Invalid Type")
var UnitInvalidUnitError = NewError("Invalid Unit")
Functions ¶
func Assert ¶
func Assert(cond bool)
Assert that condition is true if it's not panic with AssertionError
func AssertCustomError ¶
Assert that condition is true if it's not panic with specified custom error
func AssertThat ¶
func AssertThat() assertThat
func AssertThatTyped ¶
func AssertThatTyped[T any]() assertThatTyped[T]
func AssertThatTyped2 ¶
func AssertThatTyped3 ¶
func AssertThatTyped4 ¶
func AssertThatTyped5 ¶
func CheckErr ¶
Check if specified value is error Supports error, ErrorableGenericResultInterface, bool, int, uint If it gets other value it returns false
func ComplexNonInclusiveRange ¶
Range function returns an array to be used with for _, i := range ComplexNonInclusiveRange(end)
func ComplexRange ¶
Range function returns an array to be used with for _, i := range ComplexRange(end)
func ConvertToAnyArray ¶
Convert specified array of type T to array of type any
func EnsureTypeBool ¶
Ensure that value is of type T and return bool
func ExecuteAndPassthrough ¶
Execute specified function and pass through all values
func ExecuteInDebugMode ¶
func ExecuteInDebugMode(f func())
Execute specified function only in Debug Mode
func ExplodeTyped ¶
func ExplodeTyped[T any](array []T, values ...*T)
Explode array into provided references to variables with specified type T
func GetMaxForType ¶
func GetMaxForType[T NumericType]() T
GetMaxForType Get Max Value for specified numeric type
func GetMinForType ¶
func GetMinForType[T NumericType]() T
GetMinForType Get Min Value for specified numeric type
func IKnowThatThisPackageIsNotUsed ¶
func IKnowThatThisPackageIsNotUsed(x ...any)
Ignore package imported and not used
func IKnowThatThisVariableIsNotUsed ¶
func IKnowThatThisVariableIsNotUsed(x ...any)
Ignore variable declared and not used
func MakeGenerator ¶
func MakeGenerator[T any]( abortChannel <-chan struct{}, generatorFunc func(chan T) bool, ) <-chan T
Make Generator abortChannel is used to stop generator generatorFunc is generator function that is called every iteration like next. Have to have parameter for channel for writing values and returning bool if it should stop (false) or continue (true) Note that this generator is executed in goroutine
func MakeUnit ¶
Make function that will return unit This is factory of method to make function for specific unit
func NormalizeUnit ¶
Make function that will normalize to unit type
func NotImplemented ¶
func NotImplemented()
Note that something is not yet implement This function panics with NotImplementedError
func NotSupported ¶
func NotSupported()
Note that something is not supported This function panics with NotSupportedError
func PackagesUsedInDebugging ¶
func PackagesUsedInDebugging(x ...any)
Ignore package imported and not used for debugging packages
func PanicIfErrorFromOutput ¶
func PanicIfErrorFromOutput(returns ...any)
Panic if Error from specified function output has error
func Pipe ¶
Pipeline Function Call like Pipe(1, f1, f2, f3) should work similiarly to 1 |> f1 |> f2 |> f3
func PipeTyped ¶
func PipeTyped[VT any]( initialArgument VT, functions ...func(VT) VT, ) VT
Pipeline function This variant is fully typed. Note this function don't let you change type of pipeline value at any point
func PipeTypedArgReturn ¶
Pipeline Function This variant is have enforced return type and initialArgument
func PipeTypedReturn ¶
Pipeline Function This variant is have enforced return type
func PromiseAll ¶
Run all promises and wait for their results
func Range ¶
Range function returns an array to be used with for i := range Range(end) This index will start from 0 to end
func RangeNonInclusive ¶
Range function returns an array to be used with for i := range RangeNonInclusive(end) This index will start from 0 to end - 1
func StartEndNonInclusiveRange ¶
Range function returns an array to be used with for _, i := range StartEndNonInclusiveRange(end)
func StartEndRange ¶
Range function returns an array to be used with for _, i := range StartEndRange(end)
func Ternary ¶
Ternary Operation You can see this function as something like condition ? ifTrue : ifFalse
func TernaryNull ¶
func TernaryNull[V any](value V, ifNullValue V) V
Ternary that checks if value provided is nil if it's nil it uses second argument as return You can see this function as something like value ?? ifNullValue
func TernaryNullable ¶
Ternary that checks if value provided is not null according to NullableType if it's null it uses second argument as return You can see this function as something like value ?? ifNullValue but a bit more complicated because it's checks Value for OptionType (Nullable) if it is something or nothing
func TernaryResult ¶
Ternary that checks if result is ok or err and returns specified value for this condition
func Unreachable ¶
func Unreachable()
Note that something is not reachable This function panics with UnreachableError
func WithContext ¶
func WithContext[T any]( ctx ContextManagerInterface, f func(ctx ContextManagerInterface) T, ) T
Do something with context from context manager object Before executing function specified it calls Enter and Exit is called on defer
func WithGoContext ¶
func WithGoContext[T any]( ctx GoContextManagerInterface, f func(ctx GoContextManagerInterface) T, ) T
Do something with context from context manager object Before executing function specified it calls Close on defer
Types ¶
type AssertableBoolInterface ¶
type AssertableBoolInterface interface { // Method that checks if object is valid // This method should return bool if object is valid AssertBool() bool }
type AssertableInterface ¶
type AssertableInterface interface { // Method that checks if object is valid // This method should use Assert method inside or AssertCustomError method Assert() }
Assertable Interface Object
type BroadcastChannel ¶
type BroadcastChannel[T any] struct { // contains filtered or unexported fields }
Broadcast Channel Structure
func MakeBroadcastChannel ¶
func MakeBroadcastChannel[T any]() BroadcastChannel[T]
Make Broadcast Channel
func (BroadcastChannel[T]) Broadcast ¶
func (bc BroadcastChannel[T]) Broadcast(message T)
Broadcast Message to all subchannels
func (BroadcastChannel[T]) Subscribe ¶
func (bc BroadcastChannel[T]) Subscribe(id string) chan T
Subscribe to Broadcast Channel by getting your own subchannel
func (BroadcastChannel[T]) Unsubscribe ¶
func (bc BroadcastChannel[T]) Unsubscribe(id string)
Unsubscribe from Broadcast Channel by deleting the subchannel
type ContextManagerInterface ¶
type ContextManagerInterface interface { // Enter into Context Enter() // Exit from Context Exit() }
Context Manager Interface with methods on entering and exiting context This interface could be on pointer type or struct itself based if it have to manipulate data on struct
type DefaultableInterface ¶
type DefaultableInterface[T any] interface { // Get Default Value GetDefault() T }
Defaultable Interface
type EnsuredObject ¶
type ErrorableGenericResultInterface ¶
type ErrorableGenericResultInterface interface { // Check if Object has error IsError() bool // Get Error if Object has error or nil if not GetError() error }
Errorable Generic Result Interface Object This interface is meant to be used for checking if Result[T] has error or similiar object to Result[T] without option to check for underlying type of Result
type Exception ¶
type Exception struct { Message string Category ExceptionCategory }
func (*Exception) Init ¶
func (e *Exception) Init(category ExceptionCategory, msg string)
type ExceptionCategory ¶
type ExceptionCategory string
type ExtendedException ¶
func (*ExtendedException) AddNote ¶
func (e *ExtendedException) AddNote(note string)
func (ExtendedException) GoString ¶
func (e ExtendedException) GoString() string
func (ExtendedException) GuardInit ¶
func (e ExtendedException) GuardInit()
func (*ExtendedException) Init ¶
func (e *ExtendedException) Init(category ExceptionCategory, msg string)
func (ExtendedException) String ¶
func (e ExtendedException) String() string
type ExtendedUnwrappableInterface ¶
type ExtendedUnwrappableInterface[V any] interface { // Unwrap but if error occurs run specified function f instead of panic // Return underlying value UnwrapOrErr(f func(UnwrappableInterface[V])) V // Unwraps as result type for if error checks and run specified function f // instead of panic // Return result of underlying value (having err if it's found) UnwrapAsResultOrErr(f func(UnwrappableInterface[V])) Result[V] }
Unwrappable Interface Extension This functions should be implemented by any object that want to implement Unwrappable Interface This functions are based on UnwrappableInterface itself being a problem for type checks for some reason
type FeatureFlags ¶
type FeatureFlags struct { IntFlags map[string]int64 UIntFlags map[string]uint64 StringFlags map[string]string BoolFlags map[string]bool FloatFlags map[string]float64 AnyFlags map[string]any }
func GetFeatureFlags ¶
func GetFeatureFlags() *FeatureFlags
func MakeFeatureFlags ¶
func MakeFeatureFlags() *FeatureFlags
func (FeatureFlags) Dev ¶
func (f FeatureFlags) Dev() Result[string]
func (*FeatureFlags) GetAnyFlag ¶
func (f *FeatureFlags) GetAnyFlag(key string) any
func (*FeatureFlags) GetBoolFlag ¶
func (f *FeatureFlags) GetBoolFlag(key string) bool
func (*FeatureFlags) GetDefault ¶
func (f *FeatureFlags) GetDefault() *FeatureFlags
func (*FeatureFlags) GetFloatFlag ¶
func (f *FeatureFlags) GetFloatFlag(key string) float64
func (*FeatureFlags) GetIntFlag ¶
func (f *FeatureFlags) GetIntFlag(key string) int64
func (*FeatureFlags) GetStringFlag ¶
func (f *FeatureFlags) GetStringFlag(key string) string
func (*FeatureFlags) GetUintFlag ¶
func (f *FeatureFlags) GetUintFlag(key string) uint64
func (*FeatureFlags) SetAnyFlag ¶
func (f *FeatureFlags) SetAnyFlag(key string, value any)
func (*FeatureFlags) SetBoolFlag ¶
func (f *FeatureFlags) SetBoolFlag(key string, value bool)
func (*FeatureFlags) SetFloatFlag ¶
func (f *FeatureFlags) SetFloatFlag(key string, value float64)
func (*FeatureFlags) SetIntFlag ¶
func (f *FeatureFlags) SetIntFlag(key string, value int64)
func (*FeatureFlags) SetStringFlag ¶
func (f *FeatureFlags) SetStringFlag(key string, value string)
func (*FeatureFlags) SetUintFlag ¶
func (f *FeatureFlags) SetUintFlag(key string, value uint64)
type GoContextManagerInterface ¶
type GoContextManagerInterface interface {
// Close on Context Leave
Close()
}
Context Manager Interface with methods on entering and exiting context This interface is based on close method that is made in some go objects for use in defer This interface could be on pointer type or struct itself based if it have to manipulate data on struct
type GuardedObjectInterface ¶
type GuardedObjectInterface interface { // Initialize method for Guarded Object // This method is meant to be used in init method of module and contain only assert that check for example if object // is compatible with some interfaces or some version of go or something else and things like that for objects logic // to be correct GuardInit() }
Guarded Object Interface Guarded Object is meant to be object that has some guards that need to be the case or this object is not valid at all
type Nullable ¶
Nullable represents data that also can be NULL Implements UnwrappableInterface
func NullableValue ¶
Value Create a Nullable from a value
func NullableValueFromPointer ¶
ValueFromPointer Create a Nullable from a pointer
func (Nullable[T]) ExactEqual ¶
ExactEqual Check if this Nullable is exact equal to another Nullable, never using intern Equal method to check equality
func (Nullable[T]) ExpectErr ¶
Expect error value if error is not found panic with specified message
func (Nullable[T]) UnwrapAsResultOrErr ¶
Unwraps as result type for if error checks and run specified function f instead of panic Return result of underlying value (having err if it's found)
func (Nullable[T]) UnwrapOr ¶
func (n Nullable[T]) UnwrapOr(defaultVal T) T
Get underlying value or return default value if error is found
func (Nullable[T]) UnwrapOrErr ¶
Unwrap but if error occurs run specified function f instead of panic Return result of underlying value (having err if it's found)
func (Nullable[T]) UnwrapWithErr ¶
Unwrap value and error separately (Result -> Go normal returns)
func (Nullable[T]) ValueOrZero ¶
func (n Nullable[T]) ValueOrZero() T
ValueOrZero Get Value, or default zero value if it is NULL
type NumericType ¶
type Observable ¶
type Observable[T any] struct { Value T GetHandlers []func(Observable[T]) SetHandlers []func(Observable[T]) }
Observable Object
var DebugMode Observable[bool] = MakeObservable[bool](false)
DebugMode Variable
func (*Observable[T]) AddGetHandler ¶
func (o *Observable[T]) AddGetHandler(handler func(Observable[T]))
Add Get Handler Get Handler is called when GetValue is called
func (*Observable[T]) AddSetHandler ¶
func (o *Observable[T]) AddSetHandler(handler func(Observable[T]))
Add Set Handler Set Handler is called when SetValue is called
type Pipeline ¶
Pipeline object You can think of this as promise like construct without any asynchronity or like |> operator
func MakePipelineFromPointer ¶
Make New Pipeline from specified pointer to function
func (*Pipeline) EvaluateOnData ¶
Run Pipeline with arguments as data inside the pipeline and chain next operations
func (*Pipeline) GetErrorSpecial ¶
Get Error if it's nil return NilErrorErr Structure
type PipelineArray ¶
type PipelineArray struct {
Pipelines []Pipeline
}
func NewPipelineArray ¶
func NewPipelineArray(pipelines ...Pipeline) PipelineArray
Make new pipeline array
func (PipelineArray) All ¶
func (p PipelineArray) All(args ...[]any) Pipeline
Run All Pipelines inside array If any pipeline returns an error, the error is returned and execution of pipelines is stopped
func (PipelineArray) Any ¶
func (p PipelineArray) Any(args ...[]any) Pipeline
Run Pipelines inside array and stop execution when first pipeline without error will be found
func (PipelineArray) RunAll ¶
func (p PipelineArray) RunAll(args ...[]any) []any
Run All Pipelines inside array
type PipelineArrayAnyError ¶
type PipelineArrayAnyError struct { }
func (PipelineArrayAnyError) Error ¶
func (PipelineArrayAnyError) Error() string
type Promise ¶
type Result ¶
func CheckAllResults ¶
Check All Results and return first error or last ok value
func ConvertToResult ¶
Convert basic go function return value to result
func ConvertToResultMultiple ¶
Convert multiple return value function return in go style to result
func EnsureObjectImplementsInterface ¶
Ensure that specified object implements provided interface OT - Object Type IT - Interface Type self - Object Returns Result type
func EnsureTypeResult ¶
Ensure that value is of type T and return Result
func ErrWithValue ¶
Make Result with ok and error values
func MakeErrorResultWithValue ¶
Make Error Result with additional data
func PanicToError ¶
Change block that could panic into Result with error as value Note this function only catches panic errors and strings
func (Result[T]) UnwrapAsResultOrErr ¶
Unwraps as result type for if error checks and run specified function f instead of panic Return result of underlying value (having err if it's found)
func (Result[T]) UnwrapOr ¶
func (r Result[T]) UnwrapOr(defaultVal T) T
Get underlying value or return default value if error is found
func (Result[T]) UnwrapOrErr ¶
Unwrap but if error occurs run specified function f instead of panic Return result of underlying value (having err if it's found)
func (Result[T]) UnwrapWithErr ¶
Unwrap value and error separately (Result -> Go normal returns)
type SubCategoryExtendedException ¶
type SubCategoryExtendedException struct {
ExtendedException
}
func MakeException ¶
func MakeException(category ExceptionCategory, subcategory ExceptionCategory, msg string) SubCategoryExtendedException
func (SubCategoryExtendedException) GoString ¶
func (e SubCategoryExtendedException) GoString() string
func (SubCategoryExtendedException) GuardInit ¶
func (e SubCategoryExtendedException) GuardInit()
func (*SubCategoryExtendedException) Init ¶
func (e *SubCategoryExtendedException) Init(category ExceptionCategory, subcategory ExceptionCategory, msg string)
func (SubCategoryExtendedException) String ¶
func (e SubCategoryExtendedException) String() string
type SwitchResult ¶
type SwitchResult[SV any, V any] struct { // Value to Switch On SwitchValue SV // Result Value Value V // Is Switch Found SwitchFound bool }
Switch Result Type
func Switch ¶
func Switch[SV any, V any](value SV) *SwitchResult[SV, V]
Switch Statement based on provided value
func (*SwitchResult[SV, V]) Case ¶
func (s *SwitchResult[SV, V]) Case(f func(SV) (V, bool)) *SwitchResult[SV, V]
Case for Switch specified function have to take switch value and return tuple of value and bool if it was found in that case
func (*SwitchResult[SV, V]) Default ¶
func (s *SwitchResult[SV, V]) Default(f func(SV) V) *SwitchResult[SV, V]
Default Case for Switch specified function have to take switch value and return value
type ThreadSafeObject ¶
type ThreadSafeObject[T any] struct { // contains filtered or unexported fields }
Thread Safe Object that builds arround some value and make methods to set it and get it in thread safe way
func MakeThreadSafeObject ¶
func MakeThreadSafeObject[T any](obj T) ThreadSafeObject[T]
func (*ThreadSafeObject[T]) Get ¶
func (tso *ThreadSafeObject[T]) Get() T
Get underlying object value
func (*ThreadSafeObject[T]) Set ¶
func (tso *ThreadSafeObject[T]) Set(newObj T)
Set underlying object to new value
type Transaction ¶
type Transaction[T any] struct { // contains filtered or unexported fields }
Transaction implements a Saga pattern
func NewTransaction ¶
func NewTransaction[T any]() *Transaction[T]
NewTransaction instanciate a new transaction.
func (*Transaction[T]) Process ¶
func (t *Transaction[T]) Process(state T) (T, error)
Process runs the Transaction steps and rollbacks in case of errors.
func (*Transaction[T]) Then ¶
func (t *Transaction[T]) Then(exec func(T) (T, error), onRollback func(T) T) *Transaction[T]
Then adds a step to the chain of callbacks. It returns the same Transaction.
type UnionTypeConstraint ¶
type UnitValue ¶
Note that some value has specific unit like seconds
type UnwrappableInterface ¶
type UnwrappableInterface[V any] interface { // Get underlying value or panic if error Unwrap() V // Get underlying error or panic if correct value UnwrapErr() error // Get underlying value or return default value if error is found UnwrapOr(defaultVal V) V // Unwrap value and error separately (Result -> Go normal returns) UnwrapWithErr() (V, error) // Expect correct value if error is found panic with specified message Expect(err any) // Expect error value if error is not found panic with specified message ExpectErr(err any) }
Unwrappable Interface Object
Source Files ¶
- assertion.go
- broadcast_channel.go
- context_manager.go
- debug.go
- dev.go
- dump.go
- errors.go
- exception.go
- feature_flags.go
- generator.go
- global_functions.go
- ignore.go
- interfaces.go
- max_type.go
- nullable.go
- observable.go
- pattern-matching.go
- pipeline.go
- pipeline_array.go
- pipeline_func.go
- promise.go
- promise_array.go
- result.go
- result_utils.go
- theadsafe_obj.go
- transaction.go
- tuple.go
- types.go
- union.go
- unit.go
- utils.go
- variadic.go