I use Go + Postgres. To work with Postgres I use pgx. I have an array of UUID in my Postgres table and a Struct with []*uuid.UUID (from github.com/gofrs/uuid) in Go (see code below).
The problem is that I always get error when I try to use AssignTo function
cannot: decode &pgtype.UUIDArray{Elements:[]pgtype.UUID(nil), Dimensions:[]pgtype.ArrayDimension(nil), Status:0x2} into *[]*uuid.UUID
(I have tried to use all combinations with pointers and it doesn't work)
My struct (for API):
type Book struct {
AuthorIds []*uuid.UUID `json:"author_ids"`
}
My struct (for working with Postgres):
type PgBook struct {
AuthorIds pgtype.UUIDArray `db:"author_ids"`
}
And I use AssignTo
function from pgx
err := pgBook.AuthorIds.AssignTo(&book.AuthorIds)
How to solve this problem?