1. 15
    1. 2

      There’s one small omission in this, particularly relating to footnote 1, that you don’t have to use pq.Array. As long as you don’t mind using a non-standard type, lib/pq has types like [StringArray[(https://pkg.go.dev/github.com/lib/pq#StringArray) which handles reading a postgres text[] column into a (wrapped) []string - so you wouldn’t necessarily need to use pq.Array when using pgx.

      Similarly, there’s a pgtype package which can be used with either pgx or pq in database/sql mode to provide similar types. pgtype has many more types available.

    2. 1

      You should be checking the result of https://pkg.go.dev/database/sql#Rows.Err