Documentation ¶
Index ¶
- Constants
- Variables
- func Error(err error, msg string) error
- func Errorf(err error, format string, args ...interface{}) error
- func Errors(err ...error) error
- func ForEach(ctx context.Context, iter Iterator, ...) error
- func IsDone(err error) bool
- func IsNil(input interface{}) bool
- func IsNoMoreData(err error) bool
- func IsTypeOf(value Value, check Type) bool
- func NewRootScope() (*Scope, CloseFunc)
- func NumberBoundaries(input float64) (max float64, min float64)
- func NumberLowerBoundary(input float64) float64
- func NumberUpperBoundary(input float64) float64
- func ParamsFrom(ctx context.Context) (map[string]Value, error)
- func ParamsWith(ctx context.Context, params map[string]Value) context.Context
- func Random(max float64, min float64) float64
- func Random2(mid float64) float64
- func RandomDefault() float64
- func SourceError(src SourceMap, err error) error
- func TypeError(actual Type, expected ...Type) error
- func ValidateArgs(args []Value, minimum, maximum int) error
- func ValidateType(value Value, required ...Type) error
- func ValidateValueTypePairs(pairs ...PairValueType) error
- type BaseType
- type Cloneable
- type CloseFunc
- type Expression
- type ExpressionFn
- type Function
- type Functions
- type Getter
- type GetterFn
- type GetterPathIterator
- type Iterable
- type Iterator
- type Namespace
- type NativePathError
- type PairValueType
- type PathError
- type Predicate
- type RootScope
- type Scope
- func (s *Scope) Fork() *Scope
- func (s *Scope) GetVariable(name string) (Value, error)
- func (s *Scope) HasVariable(name string) bool
- func (s *Scope) MustGetVariable(name string) Value
- func (s *Scope) SetVariable(name string, val Value) error
- func (s *Scope) UpdateVariable(name string, val Value) error
- type Setter
- type SourceErrorDetail
- type SourceMap
- type Type
- type Value
Constants ¶
const (
IgnorableVariable = "_"
)
const MaxArgs = 65536
Variables ¶
var ( ErrMissedArgument = errors.New("missed argument") ErrInvalidArgument = errors.New("invalid argument") ErrInvalidArgumentNumber = errors.New("invalid argument number") ErrInvalidType = errors.New("invalid type") ErrInvalidOperation = errors.New("invalid operation") ErrNotFound = errors.New("not found") ErrNotUnique = errors.New("not unique") ErrTerminated = errors.New("operation is terminated") ErrUnexpected = errors.New("unexpected error") ErrTimeout = errors.New("operation timed out") ErrNotImplemented = errors.New("not implemented") ErrNotSupported = errors.New("not supported") ErrNoMoreData = errors.New("no more data") ErrInvalidPath = errors.New("cannot read property") ErrDone = errors.New("operation done") )
Functions ¶
func IsNoMoreData ¶ added in v0.8.0
func IsTypeOf ¶
IsTypeOf return true when value's type is equal to check type. Returns false, otherwise.
func NewRootScope ¶
func NumberBoundaries ¶ added in v0.8.0
func NumberLowerBoundary ¶ added in v0.9.0
func NumberUpperBoundary ¶ added in v0.9.0
func RandomDefault ¶ added in v0.14.0
func RandomDefault() float64
func SourceError ¶
func ValidateArgs ¶
func ValidateType ¶
ValidateType checks the match of value's type and required types.
func ValidateValueTypePairs ¶ added in v0.5.0
func ValidateValueTypePairs(pairs ...PairValueType) error
ValidateValueTypePairs validate pairs of Values and Types. Returns error when type didn't match
Types ¶
type Expression ¶
func AsExpression ¶ added in v0.16.0
type ExpressionFn ¶ added in v0.16.0
type ExpressionFn struct {
// contains filtered or unexported fields
}
type Functions ¶ added in v0.8.0
type Functions struct {
// contains filtered or unexported fields
}
Functions is a container for functions.
func NewFunctions ¶ added in v0.10.0
func NewFunctions() *Functions
NewFunctions returns new empty Functions.
func NewFunctionsFromMap ¶ added in v0.10.0
NewFunctionsFromMap creates new Functions from map, where key is the name of the function and value is the function.
func (*Functions) Get ¶ added in v0.10.0
Get returns the function with the given name. If the function does not exist it returns nil, false.
type Getter ¶ added in v0.6.0
Getter represents an interface of complex types that needs to be used to read values by path. The interface is created to let user-defined types be used in dot notation data access.
type GetterFn ¶ added in v0.16.0
GetterFn represents a type of helper functions that implement complex path resolutions.
type GetterPathIterator ¶ added in v0.16.0
type Iterable ¶ added in v0.7.0
Iterable represents an interface of a value that can be iterated by using an iterator.
type Iterator ¶ added in v0.7.0
Iterator represents an interface of a value iterator. When iterator is exhausted it must return None as a value.
type NativePathError ¶ added in v0.16.0
type NativePathError struct {
// contains filtered or unexported fields
}
NativePathError represents a default implementation of GetterError interface.
func (*NativePathError) Cause ¶ added in v0.16.0
func (e *NativePathError) Cause() error
func (*NativePathError) Error ¶ added in v0.16.0
func (e *NativePathError) Error() string
func (*NativePathError) Format ¶ added in v0.16.0
func (e *NativePathError) Format(path []Value) string
func (*NativePathError) Segment ¶ added in v0.16.0
func (e *NativePathError) Segment() int
type PairValueType ¶ added in v0.5.0
PairValueType is a supporting structure that used in validateValueTypePairs.
func NewPairValueType ¶ added in v0.10.0
func NewPairValueType(value Value, types ...Type) PairValueType
NewPairValueType it's a shortcut for creating a new PairValueType.
The common pattern of using PairValueType is: ```
pairs := []core.PairValueType{ core.PairValueType{args[0], []core.Type{types.String}}, // go vet warning core.PairValueType{Value: args[1], Types: []core.Type{types.Binary}}, // too long }
``` With NewPairValueType there is no need to type `[]core.Type{...}` and code becomes more readable and maintainable.
That is how the code above looks like with NewPairValueType: ```
pairs := []core.PairValueType{ core.NewPairValueType(args[0], types.String), core.NewPairValueType(args[1], types.Binary), }
```
type PathError ¶ added in v0.16.0
PathError represents an interface of error type which returned when an error occurs during an execution of Getter.GetIn or Setter.SetIn functions and contains segment of a given path that caused the error.
func NewPathError ¶ added in v0.16.0
NewPathError is a constructor function of NativePathError struct.
func NewPathErrorFrom ¶ added in v0.16.0
NewPathErrorFrom is a constructor function of NativePathError struct that accepts nested PathError and original segment index. It sums indexes to get the correct one that points to original path.
type RootScope ¶ added in v0.5.0
type RootScope struct {
// contains filtered or unexported fields
}
func (*RootScope) AddDisposable ¶ added in v0.5.0
type Scope ¶
type Scope struct {
// contains filtered or unexported fields
}
func (*Scope) HasVariable ¶
func (*Scope) MustGetVariable ¶ added in v0.5.0
type Setter ¶ added in v0.6.0
Setter represents an interface of complex types that needs to be used to write values by path. The interface is created to let user-defined types be used in dot notation assignment.
type SourceErrorDetail ¶ added in v0.15.0
type SourceErrorDetail struct { BaseError error ComputeError error // contains filtered or unexported fields }
func (*SourceErrorDetail) Error ¶ added in v0.15.0
func (e *SourceErrorDetail) Error() string
type SourceMap ¶
type SourceMap struct {
// contains filtered or unexported fields
}