activesupport

package
v0.0.8-b Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBlank

func IsBlank(value interface{}) bool

Types

type AnyResult

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

func Err

func Err[T comparable](err error) AnyResult[T]

func ErrText

func ErrText[T comparable](text string) AnyResult[T]

func Ok

func Ok[T comparable](val T) AnyResult[T]

func Return

func Return[T comparable](val T, err error) AnyResult[T]

func (AnyResult[T]) And

func (self AnyResult[T]) And(res Result[T]) Result[T]

And returns res if the result is Ok, otherwise returns the Err value of self.

func (AnyResult[T]) AndThen

func (self AnyResult[T]) AndThen(op func(T) Result[T]) Result[T]

AndThen calls op if the result is Ok, otherwise returns the Err value of self.

func (AnyResult[T]) Contains

func (self AnyResult[T]) Contains(val T) bool

func (AnyResult[T]) Err

func (self AnyResult[T]) Err() error

Err returns the error value.

func (AnyResult[T]) Expect

func (self AnyResult[T]) Expect(msg string) T

func (AnyResult[T]) ExpectErr

func (self AnyResult[T]) ExpectErr(msg string) error

func (AnyResult[T]) IsErr

func (self AnyResult[T]) IsErr() bool

IsErr returns true if the result if Err.

func (AnyResult[T]) IsOk

func (self AnyResult[T]) IsOk() bool

IsOk returns true if the result is Ok.

func (AnyResult[T]) Ok

func (self AnyResult[T]) Ok() Option[T]

Ok returns the success value.

func (AnyResult[T]) Or

func (self AnyResult[T]) Or(res Result[T]) Result[T]

Or returns res if the result is Err, otherwise returns the Ok value of self.

func (AnyResult[T]) OrElse

func (self AnyResult[T]) OrElse(op func(error) Result[T]) Result[T]

OrElse calls op if the result is Err, otherwise retuns the Ok value of self.

func (AnyResult[T]) String

func (self AnyResult[T]) String() string

String returns a string representation of the self.

func (AnyResult[T]) Unwrap

func (self AnyResult[T]) Unwrap() T

func (AnyResult[T]) UnwrapOr

func (self AnyResult[T]) UnwrapOr(val T) T

UnwrapOr returns the contained Ok value or a provided default.

type ErrArgument

type ErrArgument struct {
	Message string
}

ErrArgument is returned when the arguments are wrong.

func (ErrArgument) Error

func (e ErrArgument) Error() string

Error implements error interafce and return human-readable error message.

type ErrMultipleVariadicArguments

type ErrMultipleVariadicArguments struct {
	Name string
}

func (ErrMultipleVariadicArguments) Error

type FutureResult

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

func FutureErr

func FutureErr[T comparable](err error) FutureResult[T]

func FutureOk

func FutureOk[T comparable](val T) FutureResult[T]

func (FutureResult[T]) And

func (self FutureResult[T]) And(res Result[T]) Result[T]

func (FutureResult[T]) AndThen

func (self FutureResult[T]) AndThen(op func(T) Result[T]) Result[T]

func (FutureResult[T]) Contains

func (self FutureResult[T]) Contains(val T) bool

func (FutureResult[T]) Err

func (self FutureResult[T]) Err() error

func (FutureResult[T]) Expect

func (self FutureResult[T]) Expect(msg string) T

func (FutureResult[T]) ExpectErr

func (self FutureResult[T]) ExpectErr(msg string) error

func (FutureResult[T]) IsErr

func (self FutureResult[T]) IsErr() bool

func (FutureResult[T]) IsOk

func (self FutureResult[T]) IsOk() bool

func (FutureResult[T]) Ok

func (self FutureResult[T]) Ok() Option[T]

func (FutureResult[T]) Or

func (self FutureResult[T]) Or(res Result[T]) Result[T]

func (FutureResult[T]) OrElse

func (self FutureResult[T]) OrElse(op func(error) Result[T]) Result[T]

func (FutureResult[T]) Unwrap

func (self FutureResult[T]) Unwrap() T

func (FutureResult[T]) UnwrapOr

func (self FutureResult[T]) UnwrapOr(val T) T

type Hash

type Hash map[string]interface{}

func (Hash) Copy

func (h Hash) Copy() Hash

func (Hash) HasKey

func (h Hash) HasKey(k string) bool

func (Hash) IsEmpty

func (h Hash) IsEmpty() bool

func (Hash) Merge

func (h Hash) Merge(others ...Hash) Hash

func (Hash) Merged

func (h Hash) Merged(others ...Hash) Hash

func (Hash) Slice

func (h Hash) Slice(keys ...string) Hash

Slice returns a new Hash containing the entries for the given keys. Any given keys that are not found are ignored.

func (Hash) ToHash

func (h Hash) ToHash() Hash

type HashArrayConverter

type HashArrayConverter interface {
	ToHashArray() []Hash
}

type HashConverter

type HashConverter interface {
	ToHash() Hash
}

type Initializer

type Initializer interface {
	Initialize() error
}

type Option

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

func None

func None[T any]() Option[T]

func Some

func Some[T any](val T) Option[T]

func (Option[T]) IsNone

func (o Option[T]) IsNone() bool

func (Option[T]) IsSome

func (o Option[T]) IsSome() bool

func (Option[T]) String

func (o Option[T]) String() string

func (Option[T]) Unwrap

func (o Option[T]) Unwrap() T

func (Option[T]) UnwrapOr

func (o Option[T]) UnwrapOr(val T) T

type Result

type Result[T comparable] interface {
	Ok() Option[T]
	Err() error

	IsOk() bool
	IsErr() bool

	And(Result[T]) Result[T]
	AndThen(op func(T) Result[T]) Result[T]
	Or(Result[T]) Result[T]
	OrElse(op func(error) Result[T]) Result[T]

	Contains(val T) bool

	Unwrap() T
	UnwrapOr(val T) T

	Expect(msg string) T
	ExpectErr(msg string) error
}

Result is a type that represents either success (Ok) or failure (Err).

type Slice

type Slice interface {
	Contains(v interface{}) bool
}

type Str

type Str string

func (Str) IsBlank

func (s Str) IsBlank() bool

IsBlank returns true when string contains only space characters, and false otherwise.

func (Str) IsEmpty

func (s Str) IsEmpty() bool

IsEmpty returns true when lenght of string is zero, and false otherwise.

func (Str) IsNotEmpty

func (s Str) IsNotEmpty() bool

type StringSlice

type StringSlice []string

func Strings

func Strings(ss ...string) StringSlice

func (StringSlice) Contains

func (ss StringSlice) Contains(v interface{}) bool

Contains returns true if the slice contains an element with the given value.

func (StringSlice) Find

func (ss StringSlice) Find(pred func(Str) bool) Str

func (StringSlice) ToHash

func (ss StringSlice) ToHash() Hash

Jump to

Keyboard shortcuts

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