or
Returns the first truthy argument. If all arguments are falsy, returns the last argument.
Syntax
or VALUE...
Returns
any
假值包括 false、0、任何 nil 指針或接口值、任何長度為零的數組、切片、映射或字符串,以及零值 time.Time。
其他所有值都是真值。
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)有關更多信息,請參閱 Go 的 text/template 文檔。