Standard library / text/template
text/template.Template
A parsed template and its associated named definitions. Parse before executing; share immutable templates with separate writers. Expected stdout: 'Hello Ada\n'.
Formal Syntax & Structure
go syntaxgo
type Template struct { *parse.Tree
}Working Example
Example Snippetgo
package main
import ( "fmt" "os" "text/template")
func check(e error) { if e != nil { panic(e) }}
func main() { t := template.Must(template.New("greet").Parse("Hello {{.}}")) check(t.Execute(os.Stdout, "Ada")) fmt.Println()}