0
var newR[] struct {
id string
eventid string
excel_id string
userid string
hallid string
}
i := 0
for rows.Next() {
var id, eventid, excel_id, userid, hallid string
err = rows.Scan(&id, &eventid, &excel_id, &userid, &hallid)
// Here is what I want to do
newR[i].id = id
newR[i].eventid = eventid
newR[i].excel_id = excel_id
newR[i].userid = userid
newR[i].hallid = hallid
i++
}
最后收到错误消息“运行时错误:索引超出范围” 在/myapp/app/controllers/app.go(围绕线122)转到郎映射多结果
newR[i].id = id
任何建议或提示将有所帮助。谢谢。
你缺少问题中的关键信息,即你如何创建切片。我猜你对于你想存储的数据量来说太小了。 –