Search code examples
postgresqlgopgx

How to convert pgtype.Int4Array (from pgx library) to []int64 Golang type?


I use Go and Postgres (with pgx driver)

In my Postgres table I have a field with array of integers. I have created a variable to store array of integers after scanning.

var ids pgtype.Int4Array

How to convert ids to []int64?


Solution

  • Use ids.AssignTo(&sliceOfInt64)