Documentation ¶
Index ¶
- Variables
- func IsTruthy(value interface{}) bool
- type BasicFunction
- type Context
- func (c *Context) CreateWhenMissing() bool
- func (c *Context) Data() Value
- func (c *Context) Metadata(key string) interface{}
- func (c *Context) Next() (*Step, error)
- func (c *Context) Run() (Values, error)
- func (c *Context) Step(i int) *Step
- func (c *Context) WithCreateWhenMissing(create bool) *Context
- func (c *Context) WithMetadata(key string, value interface{}) *Context
- func (c *Context) WithSelector(s string) *Context
- type ErrBadSelectorSyntax
- type ErrIndexNotFound
- type ErrInvalidType
- type ErrPropertyNotFound
- type ErrUnexpectedFunctionArgs
- type ErrUnknownFunction
- type Function
- type FunctionCollection
- type InvalidIndexErr
- type Selector
- type SelectorFunc
- type SelectorResolver
- type Step
- type UnexpectedPreviousNilValue
- type UnhandledCheckType
- type UnknownComparisonOperatorErr
- type UnsupportedSelector
- type Value
- func (v Value) Append() Value
- func (v Value) Delete()
- func (v Value) FieldByName(name string) Value
- func (v Value) FirstAddressable() reflect.Value
- func (v Value) Index(i int) Value
- func (v Value) Interface() interface{}
- func (v Value) IsDencodingMap() bool
- func (v Value) IsEmpty() bool
- func (v Value) IsNil() bool
- func (v Value) Kind() reflect.Kind
- func (v Value) Len() int
- func (v Value) MapIndex(key Value) Value
- func (v Value) MapKeys() []Value
- func (v Value) Metadata(key string) interface{}
- func (v Value) NumField() int
- func (v Value) Set(value Value)
- func (v Value) String() string
- func (v Value) Type() reflect.Type
- func (v Value) Unpack(kinds ...reflect.Kind) reflect.Value
- func (v Value) WithMetadata(key string, value interface{}) Value
- type ValueNotFound
- type Values
Constants ¶
This section is empty.
Variables ¶
var AllFunc = BasicFunction{ // contains filtered or unexported fields }
var AndFunc = BasicFunction{ // contains filtered or unexported fields }
var AppendFunc = BasicFunction{ // contains filtered or unexported fields }
var CountFunc = BasicFunction{ // contains filtered or unexported fields }
var EqualFunc = BasicFunction{ // contains filtered or unexported fields }
var ErrMissingPreviousNode = errors.New("missing previous node")
ErrMissingPreviousNode is returned when findValue doesn't have access to the previous node.
var FilterFunc = BasicFunction{ // contains filtered or unexported fields }
var FilterOrFunc = BasicFunction{ // contains filtered or unexported fields }
var FirstFunc = BasicFunction{ // contains filtered or unexported fields }
var IndexFunc = BasicFunction{ // contains filtered or unexported fields }
var JoinFunc = BasicFunction{ // contains filtered or unexported fields }
var KeyFunc = BasicFunction{ // contains filtered or unexported fields }
var KeysFunc = BasicFunction{ // contains filtered or unexported fields }
var LastFunc = BasicFunction{ // contains filtered or unexported fields }
var LenFunc = BasicFunction{ // contains filtered or unexported fields }
var LessThanFunc = BasicFunction{ // contains filtered or unexported fields }
var MapOfFunc = BasicFunction{ // contains filtered or unexported fields }
var MergeFunc = BasicFunction{ // contains filtered or unexported fields }
var MetadataFunc = BasicFunction{ // contains filtered or unexported fields }
var MoreThanFunc = BasicFunction{ // contains filtered or unexported fields }
var NotFunc = BasicFunction{ // contains filtered or unexported fields }
var NullFunc = BasicFunction{ // contains filtered or unexported fields }
var OrDefaultFunc = BasicFunction{ // contains filtered or unexported fields }
var OrFunc = BasicFunction{ // contains filtered or unexported fields }
var ParentFunc = BasicFunction{ // contains filtered or unexported fields }
var PropertyFunc = BasicFunction{ // contains filtered or unexported fields }
var StringFunc = BasicFunction{ // contains filtered or unexported fields }
var ThisFunc = BasicFunction{ // contains filtered or unexported fields }
var TypeFunc = BasicFunction{ // contains filtered or unexported fields }
var UninitialisedPlaceholder interface{} = "__dasel_not_found__"
Functions ¶
Types ¶
type BasicFunction ¶
type BasicFunction struct {
// contains filtered or unexported fields
}
func (BasicFunction) AlternativeSelector ¶
func (bf BasicFunction) AlternativeSelector(part string) *Selector
func (BasicFunction) Name ¶
func (bf BasicFunction) Name() string
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context has scope over the entire query. Each individual function has its own step within the context. The context holds the entire data structure we're accessing/modifying.
func (*Context) CreateWhenMissing ¶
CreateWhenMissing returns true if the internal createWhenMissing value is true.
func (*Context) Run ¶
Run calls Next repeatedly until no more steps are left. Returns the final Step.
func (*Context) WithCreateWhenMissing ¶
WithCreateWhenMissing updates c with the given create value. If this value is true, elements (such as properties) will be initialised instead of return not found errors.
func (*Context) WithMetadata ¶
func (*Context) WithSelector ¶
WithSelector updates c with the given selector.
type ErrBadSelectorSyntax ¶
func (ErrBadSelectorSyntax) Error ¶
func (e ErrBadSelectorSyntax) Error() string
func (ErrBadSelectorSyntax) Is ¶
func (e ErrBadSelectorSyntax) Is(other error) bool
type ErrIndexNotFound ¶
type ErrIndexNotFound struct {
Index int
}
func (ErrIndexNotFound) Error ¶
func (e ErrIndexNotFound) Error() string
func (ErrIndexNotFound) Is ¶
func (e ErrIndexNotFound) Is(other error) bool
type ErrInvalidType ¶ added in v2.2.0
func (*ErrInvalidType) Error ¶ added in v2.2.0
func (e *ErrInvalidType) Error() string
func (*ErrInvalidType) Is ¶ added in v2.2.0
func (e *ErrInvalidType) Is(other error) bool
type ErrPropertyNotFound ¶
type ErrPropertyNotFound struct {
Property string
}
func (ErrPropertyNotFound) Error ¶
func (e ErrPropertyNotFound) Error() string
func (ErrPropertyNotFound) Is ¶
func (e ErrPropertyNotFound) Is(other error) bool
type ErrUnexpectedFunctionArgs ¶
func (ErrUnexpectedFunctionArgs) Error ¶
func (e ErrUnexpectedFunctionArgs) Error() string
func (ErrUnexpectedFunctionArgs) Is ¶
func (e ErrUnexpectedFunctionArgs) Is(other error) bool
type ErrUnknownFunction ¶
type ErrUnknownFunction struct {
Function string
}
func (ErrUnknownFunction) Error ¶
func (e ErrUnknownFunction) Error() string
func (ErrUnknownFunction) Is ¶
func (e ErrUnknownFunction) Is(other error) bool
type FunctionCollection ¶
type FunctionCollection struct {
// contains filtered or unexported fields
}
func (*FunctionCollection) Add ¶
func (fc *FunctionCollection) Add(fs ...Function)
func (*FunctionCollection) Get ¶
func (fc *FunctionCollection) Get(name string) (SelectorFunc, error)
func (*FunctionCollection) GetAll ¶
func (fc *FunctionCollection) GetAll() map[string]SelectorFunc
func (*FunctionCollection) ParseSelector ¶
func (fc *FunctionCollection) ParseSelector(part string) *Selector
type InvalidIndexErr ¶
type InvalidIndexErr struct {
Index string
}
InvalidIndexErr is returned when a selector targets an index that does not exist.
func (InvalidIndexErr) Error ¶
func (e InvalidIndexErr) Error() string
Error returns the error message.
func (InvalidIndexErr) Is ¶
func (e InvalidIndexErr) Is(err error) bool
Is implements the errors interface, so the errors.Is() function can be used.
type SelectorFunc ¶
SelectorFunc is a function that can be executed in a selector.
type SelectorResolver ¶
func NewSelectorResolver ¶
func NewSelectorResolver(selector string, functions *FunctionCollection) SelectorResolver
type Step ¶
type Step struct {
// contains filtered or unexported fields
}
Step is a single step in the query. Each function call has its own step. Each value in the output is simply a pointer to the actual data point in the context data.
type UnexpectedPreviousNilValue ¶
type UnexpectedPreviousNilValue struct {
Selector string
}
UnexpectedPreviousNilValue is returned when the previous node contains a nil value.
func (UnexpectedPreviousNilValue) Error ¶
func (e UnexpectedPreviousNilValue) Error() string
Error returns the error message.
func (UnexpectedPreviousNilValue) Is ¶
func (e UnexpectedPreviousNilValue) Is(err error) bool
Is implements the errors interface, so the errors.Is() function can be used.
type UnhandledCheckType ¶
type UnhandledCheckType struct {
Value interface{}
}
UnhandledCheckType is returned when the a check doesn't know how to deal with the given type
func (UnhandledCheckType) Error ¶
func (e UnhandledCheckType) Error() string
Error returns the error message.
func (UnhandledCheckType) Is ¶
func (e UnhandledCheckType) Is(err error) bool
Is implements the errors interface, so the errors.Is() function can be used.
type UnknownComparisonOperatorErr ¶
type UnknownComparisonOperatorErr struct {
Operator string
}
UnknownComparisonOperatorErr is returned when
func (UnknownComparisonOperatorErr) Error ¶
func (e UnknownComparisonOperatorErr) Error() string
Error returns the error message.
func (UnknownComparisonOperatorErr) Is ¶
func (e UnknownComparisonOperatorErr) Is(err error) bool
Is implements the errors interface, so the errors.Is() function can be used.
type UnsupportedSelector ¶
type UnsupportedSelector struct {
Selector string
}
UnsupportedSelector is returned when a specific selector type is used in the wrong context.
func (UnsupportedSelector) Error ¶
func (e UnsupportedSelector) Error() string
Error returns the error message.
func (UnsupportedSelector) Is ¶
func (e UnsupportedSelector) Is(err error) bool
Is implements the errors interface, so the errors.Is() function can be used.
type Value ¶
Value is a wrapper around reflect.Value that adds some handy helper funcs.
func Delete ¶
Delete resolves the given selector and deletes any found values. The root value may be changed in-place. If this is not desired you should copy the input value before passing it to Delete.
func Put ¶
Put resolves the given selector and writes the given value in their place. The root value may be changed in-place. If this is not desired you should copy the input value before passing it to Put.
func (Value) Delete ¶
func (v Value) Delete()
Delete deletes the current element. Depends on deleteFn since the implementation can differ depending on how the Value was initialised.
func (Value) FieldByName ¶
FieldByName returns the struct field with the given name. It returns the zero Value if no field was found.
func (Value) FirstAddressable ¶
func (Value) Index ¶
Index returns v's i'th element. It panics if v's Kind is not Array, Slice, or String or i is out of range.
func (Value) Interface ¶
func (v Value) Interface() interface{}
Interface returns the interface{} value of v.
func (Value) IsDencodingMap ¶ added in v2.3.0
func (Value) MapIndex ¶
MapIndex returns the value associated with key in the map v. It returns the zero Value if no field was found.
func (Value) Set ¶
Set sets underlying value of v. Depends on setFn since the implementation can differ depending on how the Value was initialised.
func (Value) Unpack ¶
Unpack returns the underlying reflect.Value after resolving any pointers or interface types.
func (Value) WithMetadata ¶
WithMetadata sets the given value into the values metadata.
type ValueNotFound ¶
ValueNotFound is returned when a selector string cannot be fully resolved.
func (ValueNotFound) Is ¶
func (e ValueNotFound) Is(err error) bool
Is implements the errors interface, so the errors.Is() function can be used.
type Values ¶
type Values []Value
Values represents a list of Value's.
func (Values) Interfaces ¶
func (v Values) Interfaces() []interface{}
Interfaces returns the interface values for the underlying values stored in v.
Source Files ¶
- context.go
- error.go
- func.go
- func_all.go
- func_and.go
- func_append.go
- func_count.go
- func_equal.go
- func_filter.go
- func_filter_or.go
- func_first.go
- func_index.go
- func_join.go
- func_key.go
- func_keys.go
- func_last.go
- func_len.go
- func_less_than.go
- func_map_of.go
- func_merge.go
- func_metadata.go
- func_more_than.go
- func_not.go
- func_null.go
- func_or.go
- func_or_default.go
- func_parent.go
- func_property.go
- func_string.go
- func_this.go
- func_type.go
- selector.go
- step.go
- truthy.go
- value.go