I am very new to Golang and I use the PQ package for postgres. What I'm trying to do is to prevent duplicate emails, so I have a query that checks if the user email is in the database
check_duplicate_emails, err := db.Prepare("select count(*) from profiles where email=$1") rows, err := check_duplicate_emails.Exec(email) if rows != nil { fmt.Fprintf(w,"Duplicate Email") }
This is my code above, how can I make it so that I can check it like
if rows >0 { ...}
when i try to do this i get an error
invalid operation: rows> 0 (inconsistent sql.Result and int types)
How can I solve this problem since I was looking for it to solve it now.
source share