Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidOperatorOrOperands = errors.New("invalid operator or operands")
Functions ¶
func FormatSize ¶
FormatSize takes an int64 representation of a size in bytes and returns a string representation of the size with a unit (e.g. "1G", "10M"). The size is rounded to the nearest whole number if it is an integer, otherwise it is rounded to one decimal place.
Types ¶
type FilterExpression ¶
type FilterExpression struct {
// contains filtered or unexported fields
}
FilterExpression is a parsed and compiled representation of a filter string. It can be used to efficiently test whether a set of variables matches the filter.
func CreateFilter ¶
func CreateFilter(filter string) (*FilterExpression, error)
CreateFilter parses the given filter string and returns a compiled FilterExpression that can be used to efficiently test the filter. If the filter string is not valid, an error is returned.
func (*FilterExpression) Test ¶
func (x *FilterExpression) Test(getter VariableGetter) (bool, error)
Test tests whether the set of variables provided by the getter function matches the filter expression. It returns a boolean value indicating whether the variables match the filter, as well as an error value if there was a problem evaluating the expression, like a type mismatch or a missing variable.
type Value ¶
Value is a type that can represent a number, a string, or a boolean value.
func NumberValue ¶
NumberValue creates a new Value instance that represents the given number.
type VariableGetter ¶
VariableGetter is a function type that is used to retrieve the value of a variable by its name. It takes a single string argument (the name of the variable) and returns a pointer to a Value instance that represents the value of the variable.