Documentation ¶
Overview ¶
Package selector contains a selector library for JSON and Protobuf. It's in its own standalone package only to avoid circular dependencies
nolint:govet
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ColumnSelector ¶
func ParseColumnSelector ¶
func ParseColumnSelector(str string) (ColumnSelector, error)
ParseColumnSelector parses a selector expression into an executable ColumnSelector.
func (*ColumnSelector) Select ¶
func (s *ColumnSelector) Select(meta map[string]interface{}, body interface{}) (interface{}, error)
func (ColumnSelector) String ¶
func (s ColumnSelector) String() string
type ColumnSelectorAST ¶
type ColumnSelectorAST struct { MetaKey *string `( "meta" "(" @String ")" |` Field *string ` @Ident )` Index []*Index `( "[" @@ "]" )*` Next *SelectorAST `("." @@)?` }
func (*ColumnSelectorAST) ToSelector ¶
func (s *ColumnSelectorAST) ToSelector() ColumnSelector
type ErrNotFound ¶
type ErrNotFound struct {
// contains filtered or unexported fields
}
ErrNotFound is returned when the selector references an invalid field
func (*ErrNotFound) Error ¶
func (e *ErrNotFound) Error() string
Error returns the formatted error string
type Selector ¶
type Selector []Path
Selector is a protobuf path selector.
func ParseSelector ¶
ParseSelector parses a selector expression into an executable Selector.
func (Selector) Select ¶
Select evaluates the selector expression against the given value. The only supported types are
map[string]interface{} []interface{} google.golang.org/protobuf/reflect.Message
func (Selector) SelectProto ¶
SelectProto returns the referenced value from the protobuf message. Adhering to Golang protobuf behavior, if a selector references nested value of a nil message, the default Go value will be returned. Array out of index will still panic. ErrNotFound is returned if a non-existing field is referenced. Other errors may be returned on failed type conversion. nolint: gocyclo
type SelectorAST ¶
type SelectorAST struct { Field string `@Ident` Index []*Index `( "[" @@ "]" )*` Next *SelectorAST `("." @@)?` }
func (*SelectorAST) ToSelector ¶
func (a *SelectorAST) ToSelector() Selector