Standard library / html/template

html/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"  "html/template")
func main() { fmt.Println(template.HTMLEscapeString("<b>&")) }
Go Reference