Use pointer instead of struct
This commit is contained in:
parent
853477e54a
commit
6d8f38d749
18 changed files with 187 additions and 142 deletions
|
|
@ -9,14 +9,14 @@ type Pong struct {
|
|||
State bool
|
||||
}
|
||||
|
||||
func (s Student) LastPongs() (pongs []Pong, err error) {
|
||||
func (s *Student) LastPongs() (pongs []*Pong, err error) {
|
||||
if rows, errr := DBQuery("SELECT time, state FROM student_pong WHERE id_student = ? ORDER BY time DESC", s.Id); errr != nil {
|
||||
return nil, errr
|
||||
} else {
|
||||
defer rows.Close()
|
||||
|
||||
for rows.Next() {
|
||||
var p Pong
|
||||
p := &Pong{}
|
||||
if err = rows.Scan(&p.Date, &p.State); err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue