Open elvis-hp opened 4 years ago
How about https://godoc.org/github.com/lib/pq#Array ?
Alternatively, you can/should also change the Users
type from []string
to pq.StringArray
so that pq
knows how to parse it
@tanqhnguyen thanks its work for me
Hi there! I have a model in golang:
type Transaction struct { ID string
db:"id", Status int
db:"status", Users []string
db:"users",
and this is the sql for insert:sqlStr :=
INSERT INTO transactions (data, users) VALUES (:data, :users) RETURNING idtx := st.DB.MustBegin() defer tx.Commit() _, err := tx.NamedQuery(sqlStr, txs) return err
But I got an err:sql: converting argument $17 type: unsupported type []string, a slice of string
Can someone help to fix that, thank you very much!