Documentation
¶
Index ¶
- Constants
- Variables
- func CloneArray[S ~[]E, E any](s S) S
- func SafeDeref[T any](t *T) T
- func WithContext(ctx context.Context, fn func() error, onStop ...func()) (err error)
- func WithContextPool(ctx context.Context, fn func() error, pool chan struct{}, onStop ...func()) (err error)
- type Arc
- type Enum
- type ErrX
- func (x *ErrX) AsMessage(err error) *ErrX
- func (x *ErrX) BaseCode() int
- func (x *ErrX) CmpBase(code int) bool
- func (x *ErrX) CmpExt(code int) bool
- func (x *ErrX) Error() string
- func (x ErrX) ExtCode() int
- func (x *ErrX) Extend(extCode int, messages ...string) *ErrX
- func (x *ErrX) ExtendMsg(message string, messages ...string) *ErrX
- func (x *ErrX) HasExt(code int) bool
- func (x *ErrX) Is(target error) bool
- func (x *ErrX) IsX(targetX *ErrX) bool
- func (x *ErrX) MarshalJSON() ([]byte, error)
- func (x ErrX) Message() string
- func (x ErrX) Messages() []string
- func (x ErrX) MessagesSpace() string
- type Error
- func (e *Error) BaseCode() int
- func (e *Error) Error() string
- func (e *Error) ExtendedCode() int
- func (e *Error) IfErr(fn func(err *Error) *Error) *Error
- func (e *Error) IfNotErr(fn func() *Error) *Error
- func (e *Error) IntoStd() error
- func (e *Error) Is(target *Error) bool
- func (e *Error) Join(err *Error) *Error
- func (e *Error) Joined() []*Error
- func (e Error) MarshalJSON() ([]byte, error)
- func (e *Error) Message() string
- func (e *Error) UnmarshalJSON(data []byte) error
- func (e *Error) Unwrap() []*Error
- func (e *Error) Wrap(message string) *Error
- func (e *Error) Wrapf(template string, args ...any) *Error
- type Mutex
- func (m *Mutex[V]) Borrow() Arc[*V, V]
- func (m *Mutex[V]) BorrowMut() *V
- func (m *Mutex[V]) Release()
- func (m *Mutex[V]) Return(v V)
- func (m *Mutex[V]) SetWithLock(v V)
- func (m *Mutex[V]) TryBorrow() Result[V]
- func (m *Mutex[V]) UnsafeCopy() V
- func (m *Mutex[V]) UpdateWithLock(fn func(v *V))
- func (m *Mutex[V]) WithLock(fn func(v V) V)
- type MutexSlice
- func (s *MutexSlice[V]) Clear()
- func (s *MutexSlice[V]) ClearRange(i, j int)
- func (s *MutexSlice[V]) Done() []V
- func (s *MutexSlice[V]) Get(i int) V
- func (s *MutexSlice[V]) GetCheck(i int) (V, bool)
- func (s *MutexSlice[V]) GetRange(i, j int) []V
- func (s *MutexSlice[V]) InsertAt(i int, v V) *MutexSlice[V]
- func (s *MutexSlice[V]) Iter(f func(v V) (stop bool))
- func (s *MutexSlice[V]) IterMut(f func(v *V) (stop bool))
- func (s *MutexSlice[V]) LPop() V
- func (s *MutexSlice[V]) LPopCheck() (V, bool)
- func (s *MutexSlice[V]) LPush(v V) int
- func (s *MutexSlice[V]) Len() int
- func (s *MutexSlice[V]) RPop() V
- func (s *MutexSlice[V]) RPopCheck() (V, bool)
- func (s *MutexSlice[V]) RPush(v V) int
- func (s *MutexSlice[V]) RemoveAt(i int) V
- func (s *MutexSlice[V]) Set(i int, v V)
- func (s *MutexSlice[V]) SetRange(i, j int, v []V)
- func (s *MutexSlice[V]) UnsafeCopy() []V
- func (s *MutexSlice[V]) UnsafeSlice() []V
- type Nothing
- type Option
- type Pair
- type Result
- func (Result[V]) Err(err *ErrX) Result[V]
- func (Result[V]) ErrNew(code, extCode int, msg ...string) Result[V]
- func (Result[V]) ErrNewUnknown(msg string) Result[V]
- func (r Result[V]) Error() *ErrX
- func (r Result[V]) ErrorStd() error
- func (r *Result[V]) Expect(msg string) V
- func (r Result[V]) IsErr() bool
- func (r Result[V]) IsOk() bool
- func (Result[V]) Ok(value V) Result[V]
- func (r Result[V]) Switch() switchOption
- func (r Result[V]) Unwrap() V
- func (r Result[V]) UnwrapOr(v V) V
- func (r Result[V]) UnwrapOrDefault() (v V)
- func (r Result[V]) UnwrapOrElse(fn func(err *ErrX) V) V
- type ResultN
- func (ResultN) Err(err *ErrX) ResultN
- func (ResultN) ErrNew(code, extCode int, msg ...string) ResultN
- func (ResultN) ErrNewUnknown(msg string) ResultN
- func (r ResultN) Error() *ErrX
- func (r ResultN) ErrorStd() error
- func (r ResultN) IsErr() bool
- func (r ResultN) IsOk() bool
- func (ResultN) Ok() ResultN
- func (r ResultN) Switch() switchOption
- func (r ResultN) Unwrap()
- type RwLock
- func (m *RwLock[V]) RBorrow() Arc[*V, V]
- func (m *RwLock[V]) RTryBorrow() Result[V]
- func (m *RwLock[V]) ReadAndRelease() V
- func (m *RwLock[V]) Release()
- func (m *RwLock[V]) SetWithLock(v V)
- func (m *RwLock[V]) WBorrow() Arc[*V, V]
- func (m *RwLock[V]) WRelease()
- func (m *RwLock[V]) WReturn(v V)
- func (m *RwLock[V]) WTryBorrow() Result[V]
- func (m *RwLock[V]) WithLock(fn func(v V) V)
- type Scoped
- type SecureMutexLocked
- type SecureMutexUnlocked
- type Tuple
- type Variant
Constants ¶
View Source
const ( ErrXSeparator = ";;" ErrXMessageSeparator = " : " )
View Source
const ( IsOk switchOption = true IsErr switchOption = false )
Variables ¶
View Source
var (
ErrMutexIsLocked = NewErrX(0, "mutex is locked")
)
Functions ¶
func CloneArray ¶
func CloneArray[S ~[]E, E any](s S) S
func WithContext ¶
Types ¶
type ErrX ¶ added in v0.0.23
type ErrX struct {
// contains filtered or unexported fields
}
func (*ErrX) Error ¶ added in v0.0.23
Error Example: fmt.Println(newErr(_notFound, "not found").Extend(_order).Extend(134, "test").Error()) OUT: 404: "not found";; 1000: ;; 134: "test"
func (*ErrX) MarshalJSON ¶ added in v0.0.23
MarshalJSON implements the json.Marshaler interface. Example:
{
"code": 12,
"message": "Order",
"parent": [
{
"code": 1,
"message": "Not found",
}
],
}
func (ErrX) MessagesSpace ¶ added in v0.0.37
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
func NewErrorUnknown ¶ added in v0.0.6
func (*Error) ExtendedCode ¶
func (Error) MarshalJSON ¶
func (*Error) UnmarshalJSON ¶
type Mutex ¶
type Mutex[V any] struct { // contains filtered or unexported fields }
func (*Mutex[V]) SetWithLock ¶ added in v0.0.4
func (m *Mutex[V]) SetWithLock(v V)
func (*Mutex[V]) UnsafeCopy ¶ added in v0.0.27
func (m *Mutex[V]) UnsafeCopy() V
UnsafeCopy is safe with primitive types. Type shouldn't contain interface in fields or definition.
func (*Mutex[V]) UpdateWithLock ¶ added in v0.0.4
func (m *Mutex[V]) UpdateWithLock(fn func(v *V))
type MutexSlice ¶ added in v0.0.28
type MutexSlice[V any] struct { // contains filtered or unexported fields }
func NewMutexSlice ¶ added in v0.0.28
func NewMutexSlice[V any](s []V) *MutexSlice[V]
func (*MutexSlice[V]) Clear ¶ added in v0.0.28
func (s *MutexSlice[V]) Clear()
func (*MutexSlice[V]) ClearRange ¶ added in v0.0.30
func (s *MutexSlice[V]) ClearRange(i, j int)
func (*MutexSlice[V]) Done ¶ added in v0.0.31
func (s *MutexSlice[V]) Done() []V
Done finishes the usage of the mutex and returns the slice.
func (*MutexSlice[V]) Get ¶ added in v0.0.28
func (s *MutexSlice[V]) Get(i int) V
func (*MutexSlice[V]) GetCheck ¶ added in v0.0.37
func (s *MutexSlice[V]) GetCheck(i int) (V, bool)
func (*MutexSlice[V]) GetRange ¶ added in v0.0.30
func (s *MutexSlice[V]) GetRange(i, j int) []V
func (*MutexSlice[V]) InsertAt ¶ added in v0.0.28
func (s *MutexSlice[V]) InsertAt(i int, v V) *MutexSlice[V]
func (*MutexSlice[V]) Iter ¶ added in v0.0.36
func (s *MutexSlice[V]) Iter(f func(v V) (stop bool))
func (*MutexSlice[V]) IterMut ¶ added in v0.0.36
func (s *MutexSlice[V]) IterMut(f func(v *V) (stop bool))
func (*MutexSlice[V]) LPop ¶ added in v0.0.28
func (s *MutexSlice[V]) LPop() V
func (*MutexSlice[V]) LPopCheck ¶ added in v0.0.36
func (s *MutexSlice[V]) LPopCheck() (V, bool)
func (*MutexSlice[V]) LPush ¶ added in v0.0.28
func (s *MutexSlice[V]) LPush(v V) int
func (*MutexSlice[V]) Len ¶ added in v0.0.28
func (s *MutexSlice[V]) Len() int
func (*MutexSlice[V]) RPop ¶ added in v0.0.28
func (s *MutexSlice[V]) RPop() V
func (*MutexSlice[V]) RPopCheck ¶ added in v0.0.36
func (s *MutexSlice[V]) RPopCheck() (V, bool)
func (*MutexSlice[V]) RPush ¶ added in v0.0.28
func (s *MutexSlice[V]) RPush(v V) int
func (*MutexSlice[V]) RemoveAt ¶ added in v0.0.28
func (s *MutexSlice[V]) RemoveAt(i int) V
func (*MutexSlice[V]) Set ¶ added in v0.0.28
func (s *MutexSlice[V]) Set(i int, v V)
func (*MutexSlice[V]) SetRange ¶ added in v0.0.30
func (s *MutexSlice[V]) SetRange(i, j int, v []V)
func (*MutexSlice[V]) UnsafeCopy ¶ added in v0.0.30
func (s *MutexSlice[V]) UnsafeCopy() []V
UnsafeCopy might be unsafe if array contains pointers or interfaces.
func (*MutexSlice[V]) UnsafeSlice ¶ added in v0.0.31
func (s *MutexSlice[V]) UnsafeSlice() []V
UnsafeSlice might be unsafe if you attempt to modify the MutexSlice after the call.
type Option ¶
type Option[V any] struct { // contains filtered or unexported fields }
func (Option[V]) UnwrapOrDefault ¶
func (o Option[V]) UnwrapOrDefault() V
func (Option[V]) UnwrapOrElse ¶
func (o Option[V]) UnwrapOrElse(fn func() V) V
type Result ¶
type Result[V any] struct { // contains filtered or unexported fields }
func (Result[V]) ErrNewUnknown ¶ added in v0.0.6
func (Result[V]) UnwrapOrDefault ¶
func (r Result[V]) UnwrapOrDefault() (v V)
func (Result[V]) UnwrapOrElse ¶
type ResultN ¶ added in v0.0.7
type ResultN struct {
// contains filtered or unexported fields
}
func (ResultN) ErrNewUnknown ¶ added in v0.0.7
type RwLock ¶
type RwLock[V any] struct { // contains filtered or unexported fields }
func (*RwLock[V]) RTryBorrow ¶
func (*RwLock[V]) ReadAndRelease ¶ added in v0.0.22
func (m *RwLock[V]) ReadAndRelease() V
func (*RwLock[V]) SetWithLock ¶ added in v0.0.11
func (m *RwLock[V]) SetWithLock(v V)
func (*RwLock[V]) WTryBorrow ¶
type Scoped ¶
type Scoped interface {
Lock() func()
}
func NewDebugScopedLock ¶
func NewDebugScopedLock(log ...func()) Scoped
func NewScopedLock ¶
func NewScopedLock() Scoped
type SecureMutexLocked ¶ added in v0.0.3
type SecureMutexLocked[V any] struct { // contains filtered or unexported fields }
func (SecureMutexLocked[V]) Unlock ¶ added in v0.0.3
func (m SecureMutexLocked[V]) Unlock() SecureMutexUnlocked[V]
type SecureMutexUnlocked ¶ added in v0.0.3
type SecureMutexUnlocked[V any] struct { // contains filtered or unexported fields }
func NewSecureMutex ¶ added in v0.0.3
func NewSecureMutex[V any]() SecureMutexUnlocked[V]
func NewSecureMutexV ¶ added in v0.0.22
func NewSecureMutexV[V any](v V) SecureMutexUnlocked[V]
func (SecureMutexUnlocked[V]) Lock ¶ added in v0.0.3
func (m SecureMutexUnlocked[V]) Lock() SecureMutexLocked[V]
func (SecureMutexUnlocked[V]) Set ¶ added in v0.0.22
func (m SecureMutexUnlocked[V]) Set(v V) SecureMutexUnlocked[V]
func (SecureMutexUnlocked[V]) Value ¶ added in v0.0.22
func (m SecureMutexUnlocked[V]) Value() Arc[*V, V]
Source Files
¶
Click to show internal directories.
Click to hide internal directories.