Standard library / html/template
html/template.ErrBranchEnd
Conditional paths end in incompatible contexts. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
const ErrBranchEnd ErrorCodeWorking Example
Example Snippetgo
package main
import ( "errors" "fmt" "html/template" "io")
func main() { t := template.Must(template.New("x").Parse("{{if .}}<a href=\"{{end}}{{.}}")) var e *template.Error err := t.Execute(io.Discard, nil) fmt.Println(errors.As(err, &e) && e.ErrorCode == template.ErrBranchEnd)}