What Is the Difference Between html/template and text/template

Web
Use html/template for safe web pages with automatic escaping and text/template for raw text files without escaping.

Use text/template for plain text output and html/template for HTML output that requires automatic escaping. html/template prevents XSS attacks by escaping special characters like < and > in user input, while text/template leaves them untouched.

import "html/template"

// html/template escapes < and > automatically
tmpl := template.Must(template.ParseFiles("page.html"))
tmpl.Execute(w, data)