我在將 slice 直接插入 postgres 數(shù)組時遇到問題,找不到簡單的解決方案。鑒于:favorites := []int{1,2,3,4,5}// need to _, err = db.Exec(fmt.Sprintf("UPDATE users SET favorites = '{%v}';", favorites))因為輸入是 '{[1,2,3,4,5]}' 而不是 '{1,2,3,4,5}' 我有一個錯誤。我正在使用默認(rèn) SQL 包和“github.com/lib/pq”postgres 驅(qū)動程序。
將golang切片直接插入postgres數(shù)組
拉風(fēng)的咖菲貓
2022-06-27 15:31:21