Golang text/template.HTMLEscapeString() function example

package text/template

Golang text/template.HTMLEscapeString() function usage example.

 package main

 import (
  "fmt"
  "text/template"
 )

 func main() {

  s := "<script>alert('xss attack!')</script>"

  final := template.HTMLEscapeString(s)

  fmt.Println(final)

 }

Reference :

http://golang.org/pkg/text/template/#HTMLEscapeString

Advertisement