go - How come I get cannot use type *sql.Row as type error when doing err == sql.ErrNoRows -


i trying follow example in answer given here: golang: how check empty array (array of struct)

on how check if database return empty

so have this:

err = db.queryrow("select accounts steamid=?", steamid) switch {         case err == sql.errnorows:         case err != nil:         default:                 //do stuff } 

but error:

cannot use db.queryrow("select accounts steamid=?", steamid) (type *sql.row) type error in assignment:     *sql.row not implement error (missing error method) 

not sure why worked in example not when try implement it. thanks.

you've missed scan part of example, returns error:

err := db.queryrow("select ...").scan(&id, &secret, &shortname) 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -