Cannot determine the type of a Point from PostGIS in Postgres (Golang with the pgx library)

Viewed 746

I am using Go with the pgx library to query from a Postgres database with the PostGIS plugin but I am not able to determine the type of Point from PostGIS, or better said, into what type does it fit in Golang.

Code:

    rows, err := db.conn.Query(context.Background(), "select * from point")
    if err != nil {
        return err
    }
    defer rows.Close()

    for rows.Next() {
        var uuid string
        var coordinate []float32
        err = rows.Scan(&uuid, &coordinate)
        if err != nil {
            log.Println(uuid)
            log.Println(coordinate)
        }
    }

    return rows.Err()

As expected, I am getting the following error:

can't scan into dest[1]: cannot assign &{{2 2} 2} to *[]float32

The error occurs because coordinate is a PostGIS Point, not an array of float32. What kind of type can it be attributed to in Go?

0 Answers
Related