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

I need to escape some html and want to make sure I am not missing anything.

The "html" package has:

[html.EscapeString(s string) string][1]
which will escape `'"&<>`

The "text/template" package has:

[template.HTMLEscapeString(s string) string][2]
which also escapes `'"&<>`

They seem to do the same but have slightly different approaches. Is there any differences that I am missing? If not, why 2 different built-in functions?

There is no difference. Internally they are differently implemented ([1] [2]) but results are 100% equal.

I'm pretty sure HTMLEscapeString was created for internal text/template package usage so if you need to escape HTML in your app just use html.EscapeString.