我怎么能在执行err == sql.ErrNoRows时无法使用* sql.Row类型作为类型错误

I was trying to follow the example in the answer given here: Golang: How to check for empty array (array of struct)

on how to check if a database return is empty

So I have this:

err = db.QueryRow("SELECT FROM accounts WHERE steamid=?", steamid)
switch {
        case err == sql.ErrNoRows:
        case err != nil:
        default:
                //do stuff
}

But I get the error:

cannot use db.QueryRow("SELECT FROM accounts WHERE steamid=?", steamid) (type *sql.Row) as type error in assignment:
    *sql.Row does not implement error (missing Error method)

Not sure why it worked in his example but not when I try to implement it. Thanks.

You've missed the Scan part of the example, which actually returns an error:

err := db.QueryRow("SELECT ...").Scan(&id, &secret, &shortname)