存储在 PostgreSQL 中的数据:The <b>Argentine Army</b> is. 数据类型:"content" text COLLATE "default".
当通过 Golang 打印时,它变成 The <b>Argentine Army</b> is
我需要从 PostgreSQL 打印精确数据而不转义 HTML 标签。我不确定这是 Go 还是 PostgreSQL 问题。
下面是我的 Golang 代码:
package main
import (
"database/sql"
"github.com/labstack/echo"
_ "github.com/lib/pq"
"html/template"
"io"
"log"
"net/http"
)
// type Gallery struct here
// type Template struct & function here
func main() {
e := echo.New()
// DB connection here
// Parse template & render here
e.Get("/", func(c *echo.Context) error {
rows, err := db.Query("SELECT uri, title, content FROM gallery WHERE id=123")
// Handle error here
gallery := []Gallery{}
for rows.Next() {
b := Gallery{}
err := rows.Scan(&b.Uri, &b.Title, &b.Content)
// Handle error here
gallery = append(gallery, b)
}
return c.Render(http.StatusOK, "onlytestingtpl", gallery[0])
})
e.Run(":4444")
}
富国沪深
相关分类