I'm trying to read a UUID retrieved from Postgres, using github.com/jackc/pgx, into a variable of type uuid.UUID (From the github.com/google/uuid package).
An example code could be:
var dbId = uuid.UUID
err = db.Pool.QueryRow("SELECT id FROM users WHERE objectname = $1;", objectUUID.String()).Scan(&dbId)
if err != nil {
log.Printf("Failed to fetch from database: %v", err)
return
}
The quickfix is to store the dbId in a temporary variable and then later convert said temporary variable into the correct type, but I have a feeling that there is a better, or more idiomatic, way to do it.
The error I'm getting is:
2018/02/12 07:09:18 handlers.go:187: Failed to fetch from database: can't scan into dest[1]: cannot assign &{[127 122 68 237 130 120 65 78 159 189 9 188 27 48 117 88] 2} into *uuid.UUID