html/template
documentation提到一个 HTML
类型:
Types HTML, JS, URL, and others from content.go can carry safe content that is exempted from escaping.
如何导入和使用它?
我试过下面的代码,它抛出一个“undefined: HTML”错误(Go Playground):
package main
import (
"fmt"
"html/template"
)
func main() {
fmt.Println(HTML(`<strong>Hi</strong>`))
}
最佳答案
用包名定义类型:
主要包
import (
"fmt"
"html/template"
)
func main() {
fmt.Println(template.HTML(`<strong>Hi</strong>`))
}
关于go - 如何导入HTML类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28058496/