douyi1939 2014-12-04 06:47
浏览 592
已采纳

我们还应该在Golang中关闭DB的.Prepare()吗?

From this tutorial shown that rows.Closed() must be called where rows is from stmt.Query(), is stmt.Closed() also should be called where stmt is from db.Prepare()?

// inside a function
stmt, err := db.Prepare(cmd) // cmd is SQL string
Check(err)
// should we add: defer stmt.Close()
rows, err := stmt.Query(params) // params is map/interface{}
defer rows.Close()
Check(err)
  • 写回答

2条回答 默认 最新

  • dongyi1921 2014-12-04 14:20
    关注

    The short answer is Yes. You should call stmt.Close();

    The long answer can be found in this google groups thread.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?