How to Use html/template in Go

Web
Use html/template to parse a template string and execute it with data to generate safe HTML output.

Use html/template to safely render HTML by parsing a template string, executing it with data, and writing the result to an output stream.

package main

import (
	"html/template"
	"os"
)

func main() {
	tmpl, err := template.New("page").Parse(`Hello, {{.Name}}!`)
	if err != nil {
		panic(err)
	}
	data := struct{ Name string }{Name: "World"}
	err = tmpl.Execute(os.Stdout, data)
	if err != nil {
		panic(err)
	}
}