Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

roll back for the bug

  • Loading branch information...
commit 509987ceb25603f7fa95ec34dfef2a48f2f2a6d0 1 parent f8a4f33
@astaxie authored
Showing with 8 additions and 27 deletions.
  1. +8 −27 util.go
View
35 util.go
@@ -133,37 +133,18 @@ func scanStructIntoMap(obj interface{}) (map[string]interface{}, error) {
dataStructType := dataStruct.Type()
- mapped, errs := getreflecttype(dataStructType)
-
- if errs != nil {
- return nil, errs
- }
-
- return mapped, nil
-}
-
-func getreflecttype(t reflect.Type) (map[string]interface{}, error) {
mapped := make(map[string]interface{})
- for i := 0; i < t.NumField(); i++ {
- field := t.Field(i)
+ for i := 0; i < dataStructType.NumField(); i++ {
+ field := dataStructType.Field(i)
fieldName := field.Name
- if field.Type.Kind() == reflect.Struct {
- tmpmap, err := getreflecttype(field.Type)
- if err != nil {
- return nil, err
- }
- for k, v := range tmpmap {
- if _, ok := mapped[k]; !ok {
- mapped[k] = v
- }
- }
- } else {
- mapKey := snakeCasedName(fieldName)
- value := reflect.Indirect(reflect.New(field.Type)).Interface()
- mapped[mapKey] = value
- }
+
+ mapKey := snakeCasedName(fieldName)
+ value := dataStruct.FieldByName(fieldName).Interface()
+
+ mapped[mapKey] = value
}
+
return mapped, nil
}
Please sign in to comment.
Something went wrong with that request. Please try again.