the database.Query func does not return ErrNoRows unlike the 
database.QueryRow func so how to I handle an empty set when I wish to run a 
query which returns multiple rows...

// tell other players in the room you have entered
rows_users, err := database.Query("SELECT username FROM users WHERE room = 
? AND username != ?", room, username)
// handle an empty set
if err != nil {
        if err == sql.ErrNoRows {
                fmt.Println("EMPTY SET")
        } else {
                fmt.Println(err)
                return
        }

The string "EMPTY SET" is never printed as the condition is never set...so 
continues to run through the if statement.

Surely there is is way to handle no rows with Query ??

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/6d6c7d54-1a4b-4f07-bf22-8523045ce543n%40googlegroups.com.

Reply via email to