5

I want to scan in an array of strings using the pgx library without using pq ideally. Is there a way of doing this:

sourceKeys := make([]string, 0, 1)
err := rows.Scan(
    pq.Array(&sourceKeys),
)

without using the pq library?

  • You can do it without lib/pq but you'll have to implement the [`sql.Scanner`](https://pkg.go.dev/database/sql@go1.18#Scanner) yourself. The implementation will have to be able to correctly parse a raw postgres text array. Or you can use the [`jackc/pgtype`](https://github.com/jackc/pgtype) package which is intended to be used with `pgx` (same author and mentioned in pgx's readme). – mkopriva Apr 01 '22 at 05:45

0 Answers0