html.EscapeString()和template.HTMLEscapeString()之间有什么区别?

html.EscapeString()和template.HTMLEscapeString()之间有什么区别?,html,go,escaping,Html,Go,Escaping,我需要避开一些html,并希望确保我没有遗漏任何内容 “html”包具有: [html.EscapeString(s string) string][1] which will escape `'"&<>` [template.HTMLEscapeString(s string) string][2] which also escapes `'"&<>` [html.EscapeString(s string)string][1] 它将逃逸`“&`

我需要避开一些html,并希望确保我没有遗漏任何内容

“html”包具有:

[html.EscapeString(s string) string][1]
which will escape `'"&<>`
[template.HTMLEscapeString(s string) string][2]
which also escapes `'"&<>`
[html.EscapeString(s string)string][1]
它将逃逸`“&`
“文本/模板”包具有:

[html.EscapeString(s string) string][1]
which will escape `'"&<>`
[template.HTMLEscapeString(s string) string][2]
which also escapes `'"&<>`
[template.HTMLEscapeString(s string)string][2]
它也逃逸了`“&`

他们似乎做了同样的事情,但方法略有不同。我遗漏了什么区别吗?如果没有,为什么有两个不同的内置函数?

没有区别。在内部,它们的实现方式不同(),但结果是100%相等的

我很确定
htmlescapesting
是为内部
text/template
包使用而创建的,所以如果你需要在应用程序中转义HTML,只需使用
HTML.EscapeString