Inserting an array into a Postgresql database
Implement database/sql/driver.Valuer with a custom type:
type int64array []int64
func (a int64array) Value() (driver.Value, error) {
// Format a in PostgreSQL's array input format {1,2,3} and return it as as string or []byte.
}
Arrays are supported in github.com/lib/pq
since 2016 Aug 6th. OP's statement could be written as:
_, err := db.Exec(
"INSERT INTO history VALUES ($1, $2, $3, $4)",
rand.Int63(),
pq.Array(t.productids), // <-------
card.cid,
t.salepoint,
)