golang Gorp Postgres select仅返回一行

I just started go programming.

In Go, I used gorp.v1 with lib pq, since my database is Postgres. I have written a Postgres function and call it from gorp and libpq. The function returns multiple rows. But when I call it from grop dbmap it returns only one row.

Below is the code sample:

rowData := []*RoadData{}

_, err := db.PgMap.Select(&rowData, "SELECT * FROM pgr_roadDataCost(1000, 'roadnetwork',lattitidue1,logitude1,lattitidue2,logitude2)")

When I print rowData, it contains only one row, but actually there are multiple rows.

There is a SelectOne method :

var roadData RoadData
err := db.PgMap.SelectOne(&roadData, "SELECT * FROM pgr_roadDataCost(1000, 'roadnetwork',lattitidue1,logitude1,lattitidue2,logitude2)")

If your query returns only one row, you can use db.QueryRow:

db.QueryRow("select name from users where id = ?", 1).Scan(&name)

You can read here for more details.