これは、ドキュメントに従って動作するはずの非常に単純なコードです。
package controllers
import (
"github.com/astaxie/beego"
"github.com/astaxie/beego/orm"
"fmt"
)
type TestController struct {
beego.Controller
}
type Ticket struct {
Id int `orm:"auto"`
EventId int
EntryId int
}
func (this *TestController) Get() {
o := orm.NewOrm()
tickets := new([]*Ticket)
qs, _ := o.QueryTable(new(Ticket)).Filter("EventId", 2).All(&tickets)
fmt.Print(qs)
this.Ctx.WriteString("test controller")
}
func init(){
orm.RegisterModel(new(Ticket))
}
これにより、Beego が次のエラーでクラッシュします。
GoEventKeeper:wrong object type `*[]*controllers.Ticket` for rows scan, need *[]*rohan.com/GoEventKeeper/controllers.Ticket or *rohan.com/GoEventKeeper/controllers.Ticket
これはあってはならないことだと思います。明らかに、コントローラー内に Ticket 構造体が 1 つしかないので、間違った値を互いに比較しているように見えますか?
これを解決するにはどうすればよいですか?