rename ScanStruct to ScanStructByIndex and ScanStruct2 to ScanStructByName
This commit is contained in:
parent
ea82aa0fbf
commit
4bcb0fbd6a
4
db.go
4
db.go
|
@ -252,7 +252,7 @@ type Rows struct {
|
|||
}
|
||||
|
||||
// scan data to a struct's pointer according field index
|
||||
func (rs *Rows) ScanStruct(dest ...interface{}) error {
|
||||
func (rs *Rows) ScanStructByIndex(dest ...interface{}) error {
|
||||
if len(dest) == 0 {
|
||||
return errors.New("at least one struct")
|
||||
}
|
||||
|
@ -319,7 +319,7 @@ func fieldByName(v reflect.Value, name string) reflect.Value {
|
|||
}
|
||||
|
||||
// scan data to a struct's pointer according field name
|
||||
func (rs *Rows) ScanStruct2(dest interface{}) error {
|
||||
func (rs *Rows) ScanStructByName(dest interface{}) error {
|
||||
vv := reflect.ValueOf(dest)
|
||||
if vv.Kind() != reflect.Ptr || vv.Elem().Kind() != reflect.Struct {
|
||||
return errors.New("dest should be a struct's pointer")
|
||||
|
|
Loading…
Reference in New Issue