func TestPushToPTRSlice(t *testing.T) { sl := []*Foo{} slval := meta.Addressable(&sl) meta.Push(slval, meta.DirectValueOf(&Foo{123})) meta.Push(slval, meta.DirectValueOf(&Foo{456})) assert.Equal(t, len(sl), 2) assert.Equal(t, sl[0].Id, 123) assert.Equal(t, sl[1].Id, 456) }
func (scan *Scan) All(rows *sql.Rows) error { writeTo := meta.Addressable(scan.To) for rows.Next() { record := meta.CreateElement(scan.To) if err := scan.Scan(rows, record); err != nil { return err } meta.Push(writeTo, record) } return nil }