duanluo5096 2015-08-25 10:03
浏览 866
已采纳

我怎么能在执行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.

  • 写回答

1条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 中文语料库检索构式 求助
      • ¥20 boost升压电路频率和占空比的选择
      • ¥15 Linux gcc升级问题
      • ¥100 如何封禁域名,让app打不开呢?
      • ¥15 通过安卓命令如何打开控制中心
      • ¥15 Nginx 配合Django 丢样式
      • ¥15 求问Python学生成绩管理系统的问题
      • ¥15 求🐏了个🐏第二关的代码,c语言
      • ¥20 类似羊了个羊修改三个不同图片才能消除
      • ¥15 环绕字符串的子字符串个数(实在做不出来,只能做到普通字符串)