Standard library / text/template

text/template.ExecError

Wraps a template evaluation failure; a writer error is returned directly. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
type ExecError struct {  Name string  Err  error}

Working Example

Example Snippetgo
package main
import (  "errors"  "fmt"  "io"  "text/template")
func main() {  t := template.Must(template.New("x").Option("missingkey=error").Parse("{{.missing}}"))  var e template.ExecError  fmt.Println(errors.As(t.Execute(io.Discard, map[string]int{}), &e))}
Go Reference