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
任何建議或提示將有所幫助。謝謝。
你缺少問題中的關鍵信息,即你如何創建切片。我猜你對於你想存儲的數據量來說太小了。 –