tpl, err := template.ParseFiles("mytemplate.html") if err != nil { log.Fatal(err) }
tpl, err := template.ParseGlob("templates/*.html") if err != nil { log.Fatal(err) }
const myTemplate = `{{.Title}}` tpl, err := template.New("mytemplate").Parse(myTemplate) if err != nil { log.Fatal(err) }This code creates a new template with the name "mytemplate" and a simple placeholder for a title. The template is stored in memory as a string constant. The package library being used in these examples is the "html/template" package.