Documentation
¶
Index ¶
- type Expr
- type Option
- type Result
- func (r *Result) Bool() (bool, error)
- func (r *Result) Equal(other *Result) bool
- func (r *Result) Float32() (float32, error)
- func (r *Result) Float64() (float64, error)
- func (r *Result) Int() (int, error)
- func (r *Result) Int16() (int16, error)
- func (r *Result) Int32() (int32, error)
- func (r *Result) Int64() (int64, error)
- func (r *Result) Int8() (int8, error)
- func (r *Result) Interface() any
- func (r *Result) IsNil() bool
- func (r *Result) IsTruthy() bool
- func (r *Result) IsZero() bool
- func (r *Result) String() (string, error)
- func (r *Result) Uint() (uint, error)
- func (r *Result) Uint16() (uint16, error)
- func (r *Result) Uint32() (uint32, error)
- func (r *Result) Uint64() (uint64, error)
- func (r *Result) Uint8() (uint8, error)
- func (r *Result) Value() reflect.Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Expr ¶
type Expr struct {
// contains filtered or unexported fields
}
Expr is a compiled dcell expression that can be evaluated.
func MustCompile ¶
MustCompile compiles a dcell expression string into an Expr and panics if it fails.
func (*Expr) MarshalText ¶
MarshalText marshals the expression to a textual format.
func (*Expr) MustEval ¶
MustEval evaluates the expression with the provided value context and panics if it fails.
func (*Expr) UnmarshalText ¶
UnmarshalText unmarshals a dcell expression from text.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is an option that can be used to configure the dcell compiler.
func WithFunc ¶
WithFunc adds a function to the dcell function table.
fn may be any function type, including variadic functions, and must return (T, error) or just T. The implementation will automatically handle conversions from the input types to the function's parameter types and from the function's return types to the output types.
Example:
dcell.WithFunc(func(base, exponent int) (int, error) { return int(math.Pow(float64(base), float64(exponent))), nil })
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
Result is the result of evaluating a dcell expression. This may be a
func (*Result) Equal ¶
Equal returns true if the two results are semantically equal. This is a deep comparison of the underlying values, but not the underlying storage or types -- meaning that two results carrying different types with the same value are considered equal, such as `int(42)` and `int8(42)`.
This check is done recursively for structures, maps, and slices.
func (*Result) Float32 ¶
Float32 attempts to convert the result to a 32-bit floating point value. If the value is not convertible to a string, or would lose information in the conversion, an error is returned.
func (*Result) Float64 ¶
Float64 attempts to convert the result to a 64-bit floating point value. If the value is not convertible to a string, or would lose information in the conversion, an error is returned.
func (*Result) Int ¶
Int attempts to convert the result to a signed integer value. If the value is not convertible to a string, or would lose information in the conversion, an error is returned.
func (*Result) Int16 ¶
Int16 attempts to convert the result to a 16-bit signed integer value. If the value is not convertible to a string, or would lose information in the conversion, an error is returned.
func (*Result) Int32 ¶
Int32 attempts to convert the result to a 32-bit signed integer value. If the value is not convertible to a string, or would lose information in the conversion, an error is returned.
func (*Result) Int64 ¶
Int64 attempts to convert the result to a 64-bit signed integer value. If the value is not convertible to a string, or would lose information in the conversion, an error is returned.
func (*Result) Int8 ¶
Int8 attempts to convert the result to an 8-bit signed integer value. If the value is not convertible to a string, or would lose information in the conversion, an error is returned.
func (*Result) Interface ¶
Interface returns the underlying value of the result. If the IsNil would return true, this will return nil.
func (*Result) IsNil ¶
IsNil returns true if there is no value in the result, or if the value that would be returned is a nil value -- such as a pointer, slice, or map.
func (*Result) IsTruthy ¶
IsTruthy returns true if the result is a truthy value. Truthiness is determined by the following rules:
- Numeric values are truthy if they are not zero.
- Strings are truthy if they are not empty.
- Slices and maps are truthy if they are not nil and contain at least one element.
- Pointers are truthy if they are not nil.
- Structs are always truthy
- All else is considered truthy only if reflect.Value.IsZero returns false.
func (*Result) Uint ¶
Uint attempts to convert the result to an unsigned integer value. If the value is not convertible to a string, or would lose information in the conversion, an error is returned.
func (*Result) Uint16 ¶
Uint16 attempts to convert the result to a 16-bit unsigned integer value. If the value is not convertible to a string, or would lose information in the conversion, an error is returned.
func (*Result) Uint32 ¶
Uint32 attempts to convert the result to a 32-bit unsigned integer value. If the value is not convertible to a string, or would lose information in the conversion, an error is returned.
func (*Result) Uint64 ¶
Uint64 attempts to convert the result to a 64-bit unsigned integer value. If the value is not convertible to a string, or would lose information in the conversion, an error is returned.
Directories
¶
Path | Synopsis |
---|---|
internal
|
|
errs
Package errs is an internal package that provides shared errors across the go-dcell library.
|
Package errs is an internal package that provides shared errors across the go-dcell library. |
intcmp
Package intcmp provides integer comparison functions for comparing signed and unsigned integers.
|
Package intcmp provides integer comparison functions for comparing signed and unsigned integers. |
intconv
Package intconv provides functions for narrowing conversions between signed and unsigned integers.
|
Package intconv provides functions for narrowing conversions between signed and unsigned integers. |
invocation
Package invocation provides a mechanism for defining and invoking functions in a yamlpath expression.
|
Package invocation provides a mechanism for defining and invoking functions in a yamlpath expression. |
invocation/arity
Package arity is a micro-package for providing the Arity type, which is used to identify whether the number of arguments being provided to an invocation is valid.
|
Package arity is a micro-package for providing the Arity type, which is used to identify whether the number of arguments being provided to an invocation is valid. |
levenshtein
Package levenshtein provides a function to calculate the Damerau-Levenshtein distance between two strings.
|
Package levenshtein provides a function to calculate the Damerau-Levenshtein distance between two strings. |