package model type IndexElement struct { Id uint Title string } type Index []IndexElement func (d *Index) FromDB() error { query, err := GetSql(`index-select`) if err != nil { return err } rows, err := db.Query(query) if err != nil { return err } for rows.Next() { var i IndexElement if err = rows.Scan(&i.Id, &i.Title); err != nil { return err } *d = append(*d, i) } return nil }