The Go database/sql Postgres adapter does not support LastInsertId. From the docs:
pq does not support the LastInsertId() method of the Result type in database/sql. To return the identifier of an INSERT (or UPDATE or DELETE), use the Postgres RETURNING clause with a standard Query or QueryRow call.
But the Go database/sql docs recommend not using Query to modify the database because it:
reserves a database connection until the sql.Rows is closed. Since there might be unread data (e.g. more data rows), the connection can not be used. In the example above, the connection will never be released again.
The docs also say "you should never use Query() like this."
Most people recommend using QueryRow to do an INSERT with Postgres if you need the resultant row. I don't fully understand the technical reasoning given by the docs, but its seems to conflict with what I've read. Is it safe and considered good practice to use QueryRow to do an INSERT?