or
Returns the first truthy argument. If all arguments are falsy, returns the last argument.
Syntax
or VALUE...
Returns
any
The falsy values are false, 0, any nil pointer or interface value, any array, slice, map, or string of length zero, and zero time.Time values.
Everything else is truthy.
The or function evaluates the arguments from left to right, and returns when the result is determined.
{{ or 0 1 2 }} → 1 (int)
{{ or false "a" 1 }} → a (string)
{{ or 0 true "a" }} → true (bool)
{{ or false "" 0 }} → 0 (int)
{{ or 0 "" false }} → false (bool)
{{ or true (math.Div 1 0) }} → true (bool)See Go’s text/template documentation for more information.
Last updated:
February 4, 2026
:
content: Indicate data types returned by the or function (b1722ac6b)
Improve this page