Escape HTML Content in Go

Posted by yhuang
Public (Editable by Users)
Go
Edit
package main

import (
	"fmt"
	"html"
)

func main() {

	unescaped := `<script>alert(123);</script>`
	escaped := html.EscapeString(unescaped)
	fmt.Println(escaped)
}