第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Golang+PostgreSQL - 如何在不轉(zhuǎn)義 HTML 標簽的情況下打印精確查詢?

Golang+PostgreSQL - 如何在不轉(zhuǎn)義 HTML 標簽的情況下打印精確查詢?

Go
料青山看我應如是 2021-10-18 09:57:18
存儲在 PostgreSQL 中的數(shù)據(jù):The <b>Argentine Army</b> is. 數(shù)據(jù)類型:"content" text COLLATE "default".當通過 Golang 打印時,它變成 The &lt;b&gt;Argentine Army&lt;/b&gt; is我需要從 PostgreSQL 打印精確數(shù)據(jù)而不轉(zhuǎn)義 HTML 標簽。我不確定這是 Go 還是 PostgreSQL 問題。下面是我的 Golang 代碼:package mainimport (    "database/sql"    "github.com/labstack/echo"    _ "github.com/lib/pq"    "html/template"    "io"    "log"    "net/http")// type Gallery struct here// type Template struct & function herefunc 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")}
查看完整描述

1 回答

?
富國滬深

TA貢獻1790條經(jīng)驗 獲得超9個贊

這是由 html 模板引起的 - 您可以使用如下函數(shù):


func unsafe(x string) template.HTML {

    return template.HTML(x)

}

獲取“未轉(zhuǎn)義”的 html。


查看完整回答
反對 回復 2021-10-18
  • 1 回答
  • 0 關注
  • 165 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號