Standard library / text/template

text/template.HTMLEscapeString()

Returns a string with HTML special characters escaped. Expected stdout: '<b>&\n'.

Formal Syntax & Structure

go syntaxgo
func HTMLEscapeString(s string) string

Parameters & Attributes

NameTypeDescription
sstringString to escape.

Return Value

string

Returns a string with HTML special characters escaped.

Working Example

Example Snippetgo
package main
import (  "fmt"  "text/template")
func main() { fmt.Println(template.HTMLEscapeString("<b>&")) }
Go Reference