Standard library / text/template
text/template.HTMLEscape()
Writes HTML-escaped bytes; this helper is not a complete context-aware renderer. Expected stdout: '<b>&\n'.
Formal Syntax & Structure
go syntaxgo
func HTMLEscape(w io.Writer, b []byte)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| w | io.Writer | Destination writer. |
| b | []byte | Bytes to escape. |
Working Example
Example Snippetgo
package main
import ( "fmt" "os" "text/template")
func main() { template.HTMLEscape(os.Stdout, []byte("<b>&")); fmt.Println() }