go - Golang+PostgreSQL - How to print exact query without escape HTML tags? -
data stored in postgresql: the <b>argentine army</b> is
. data type: "content" text collate "default"
.
when print through golang, become the <b>argentine army</b> is
i need print exact data postgresql without escaping html tags. i'm not sure if go or postgresql issue.
below golang codes:
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 gallery id=123") // handle error here gallery := []gallery{} 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") }
this caused html template - use function such as:
func unsafe(x string) template.html { return template.html(x) }
to 'unescaped' html.
Comments
Post a Comment