我用的github.com/go-sql-driver/mysql这个驱动,我像下面这样写没有报错,但是里面的数据为空或者0typedatastruct{idintnamestringweightint}rows,_:=db.Query("select*fromtestwhereid=?",2)forrows.Next(){line:=data{}err=rows.Scan(&line)log.Println(line)}运行结果2017/07/1713:37:50{00}存到map的代码rows,_:=db.Query("select*fromtestwhereid=?",2)columns,_:=rows.Columns()length:=len(columns)forrows.Next(){value:=make([]interface{},length)columnPointers:=make([]interface{},length)fori:=0;i
添加回答
举报
0/150
提交
取消