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