HUGO
Menu
GitHub 90622 stars Mastodon

not

Returns the boolean negation of its single argument.
Syntax
not VALUE
Returns
bool

Usage

The not function returns the boolean negation of its single argument. Unlike the and and or functions, the not function always returns a boolean value.

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.

See Go’s text/template documentation for more information.

Examples

{{ not true }} → false
{{ not false }} → true

{{ not 1 }} → false
{{ not 0 }} → true

{{ not "x" }} → false
{{ not "" }} → true

Casting any value to a boolean value by calling the function twice:

{{ 42 | not | not }} → true
{{ "" | not | not }} → false