func Read(query QueryFn, scanTo interface{}, allparams []interface{}) error { sql, params, err := ResolveReadParams(allparams) if err != nil { return err } if !meta.IsPointer(scanTo) { return errors.New("A pointer has to be passed for scanning rows to.") } if meta.IsSlice(scanTo) { return ReadAll(query, scanTo, sql, params) } return ReadOne(query, scanTo, sql, params) }
func TestIsPointer(t *testing.T) { assert.True(t, meta.IsPointer(&Foo{})) assert.True(t, meta.IsPointer(&[]Foo{})) assert.False(t, meta.IsPointer(Foo{})) assert.False(t, meta.IsPointer(*&Foo{})) }