如何导入HTML类型?

How to import the HTML type?

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>`))
}

playground example