Hi.
I have a problem. Did go get -u, and now that that worked earlier, produces an error at compilation.
Structure
type Domain struct {
tableName struct{} `sql:"domain,alias:d"`
Id int `sql:",pk" json:"id"`
Domain string `json:"domain"`
Description string `json:"description"`
Aliases int `json:"aliases"`
Mailboxes int `json:"mailboxes"`
Maxquota int `json:"maxquota"`
Created time.Time `json:"created"`
Modified time.Time `json:"modified"`
Active bool `json:"active"`
}
Call
func (d *Domain) GetById() error {
err := Db.Model(&d).Where("id=?", d.Id).Select()
return err
}
I can not understand what has changed?
Change Db.Model(&d) to Db.Model(d) since d is already a pointer.
If you do as you say, I get an error. pg: Model (non-pointer [] db.Domain).
Yeah, but that is completely different code. Overall you should pass a pointer to the object, not a pointer to a pointer as in your question.
Most helpful comment
Change
Db.Model(&d)toDb.Model(d)sincedis already a pointer.