Example #1
0
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)
}
Example #2
0
File: scan.go Project: rjp/crud
func (scan *Scan) One(rows *sql.Rows) error {
	for rows.Next() {
		return scan.Scan(rows, meta.DirectValueOf(scan.To))
	}

	return errors.New("No matching rows found.")
}