.
operator
or []
operator. Elements of arrays and slices can be accessed with
[]
operator. Negative indices are supported with -1
being
the last element.
The in
operator can be used to check if an item is in an array or a map.
??
operator can be used to return the left-hand side if it is not nil
,
otherwise the right-hand side is returned.
[:]
can be used to access a slice of an array.
For example, variable array
is [1, 2, 3, 4, 5]
:
|
can be used to pass the result of the left-hand side
expression as the first argument of the right-hand side expression.
For example, expression split(lower(user.Name), " ")
can be written as:
str
.
If the optional chars
argument is given, it is a string specifying the set of characters to be removed.
str
if it starts with that prefix.
str
if it ends with that suffix.
str
to uppercase.
str
to lowercase.
str
at each instance of the delimiter and returns an array of substrings.
str
after each instance of the delimiter.
old
in string str
with new
.
str
n
times.
str
or -1 if not found.
str
or -1 if not found.
true
if string str
starts with the given prefix.
true
if string str
ends with the given suffix.
str
as nanoseconds. Use the additional functions to return it in a different unit.
Valid time units are “ns”, “us” (or “µs”), “ms”, “s”, “m”, “h”.
str
into a date representation.
If the optional format
argument is given, it is a string specifying the format of the date.
The format string uses the same formatting rules as the standard
Go time package.
If the optional timezone
argument is given, it is a string specifying the timezone of the date.
If the format
argument is not given, the v
argument must be in one of the following formats:
n1
and n2
.
n1
and n2
.
initialValue
argument can be used to specify the initial value of the accumulator.
If initialValue
is not given, the first element of the array is used as the initial value.
Following variables are available in the predicate:
#
- the current element#acc
- the accumulator#index
- the index of the current elementnil
.
nil
.
n
elements from an array. If the array has fewer than n
elements, returns the whole array.
order
argument can be used to specify the order of sorting: asc
or desc
.
order
argument can be used to specify the order
of sorting: asc
or desc
.
v
.
Returns on of the following types: nil
, bool
, int
, uint
, float
, string
, array
, map
.
For named types and structs, the type name is returned.
v
into a string representation.
v
to its JSON string representation.
v
and returns the corresponding value.
v
into Base64 format.
v
back to its original form.
v
. If the index is out of range, returns nil
.
Or the key does not exist, returns nil
.
#
symbol is used.
#
symbol (#.Value
becomes .Value
).
{
}
can be omitted:
$env
variable$env
variable is a map of all variables passed to the expression.
Comment | /* */ or // |
Boolean | true , false |
Integer | 42 , 0x2A |
Float | 0.5 , .5 |
String | ”foo” , ‘bar’ |
Array | [1, 2, 3] |
Map | {a: 1, b: 2, c: 3} |
Nil | nil |
Arithmetic | + , - , * , / , % (modulus), ^ or ** (exponent) |
Comparison | == , != , < , > , <= , >= |
Logical | not or ! , and or && , or or || |
Conditional | ?: (ternary), ?? (nil coalescing) |
Membership | [] , . , ?. , in |
String | + (concatenation), contains , startsWith , endsWith |
Regex | matches |
Range | .. |
Slice | [:] |
Pipe | | |