如何将字符串从unicode转换为html实体

I'm trying to convert an Arabic string like this:

ص

to this:

ص

Is there a way (or package) to do it in Go?

That character is not special in HTML, so you can include it as-is in the output, just be sure to set the proper encoding of the document.

Note that to escape special characters in strings, you may use html.EscapeString(). But because ص is not special in HTML, that will not change.

If for some reason you do need to escape it, you may simply use the decimal representation of the rune:

fmt.Println(html.EscapeString("ص"))
fmt.Printf("&#%d;", 'ص')

Outputs (try it on the Go Playground):

ص
ص