其他的增删改都正常,就是查询代码出错
~~~
func select1(w http.ResponseWriter, r *http.Request) {
db, err := sql.Open("mysql", "root:root@tcp(127.0.0.1:3306)/test?charset=utf8")
checkErr(err)
//rows,err :=db.Query("select uid ,age form user_list where user ='guest'")
rows, err := db.Query("select * from user_list")
checkErr(err)
for rows.Next() {
var uid int
var user string
//var age int
rows.Columns()
err = rows.Scan(&uid, &user)
checkErr(err)
fmt.Fprintln(w, uid)
fmt.Fprintln(w, user)
//fmt.Fprintln(w, age)
}
//关闭数据库
db.Close()
}
~~~
sql: expected 4 destination arguments in Scan, not 2
sql: expected 4 destination arguments in Scan, not 2
2017/09/11 13:56:43 http: panic serving 127.0.0.1:17112: sql: expected 4 destination arguments in Scan, not 2
楼上说的很清楚了<a href="/user/hellsam" title="@hellsam">@hellsam</a>
#6
更多评论
<a href="/user/channel" title="@channel">@channel</a> 没有错误信息 直接在http无法打开。。
其他的增删改都正常 我这个代码有没有问题 写法
#2