Standard library / html/template

html/template.IsTrue()

Reports template conditional truth and whether the value has a defined truth interpretation. Expected stdout: 'false true\n'.

Formal Syntax & Structure

go syntaxgo
func IsTrue(val any) (truth, ok bool)

Parameters & Attributes

NameTypeDescription
valanyValue whose template truth is tested.

Return Value

(truth, ok bool)

Reports template conditional truth and whether the value has a defined truth interpretation.

Working Example

Example Snippetgo
package main
import (  "fmt"  "html/template")
func main() { v, ok := template.IsTrue([]int{}); fmt.Println(v, ok) }
Go Reference