add comment

This commit is contained in:
Jay 2018-04-25 15:53:26 +08:00
parent b75453cee9
commit 4b015522fe

View File

@ -25,6 +25,7 @@ func ScanToStruct(rows *sql.Rows, ss interface{}) (ok bool, err error) {
return true, nil
}
// ScanToStructAll -
func ScanToStructAll(rows *sql.Rows, ss interface{}) error {
sliceVal := reflect.Indirect(reflect.ValueOf(ss))
if sliceVal.Kind() != reflect.Slice {
@ -53,6 +54,7 @@ func ScanToStructAll(rows *sql.Rows, ss interface{}) error {
return nil
}
// ResultToMap -
func ResultToMap(r *sql.Rows) ([]map[string]interface{}, error) {
result := make([]map[string]interface{}, 0)
cols, err := r.Columns()
@ -82,6 +84,7 @@ func ResultToMap(r *sql.Rows) ([]map[string]interface{}, error) {
return result, nil
}
// MapToStruct -
func MapToStruct(data map[string]interface{}, out interface{}) error {
ss := reflect.ValueOf(out).Elem()
for i := 0; i < ss.NumField(); i++ {