working on auth.
mailer, basic setup with html template and a dev treansport
This commit is contained in:
33
util/structs/structs.go
Normal file
33
util/structs/structs.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package structs
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
)
|
||||
|
||||
func Map(obj interface{}) map[string]interface{} {
|
||||
result := make(map[string]interface{})
|
||||
|
||||
val := reflect.ValueOf(obj)
|
||||
|
||||
if val.Kind() == reflect.Ptr {
|
||||
val = val.Elem()
|
||||
}
|
||||
|
||||
typ := val.Type()
|
||||
|
||||
for i := 0; i < val.NumField(); i++ {
|
||||
fieldName := typ.Field(i).Name
|
||||
fieldValueKind := val.Field(i).Kind()
|
||||
var fieldValue interface{}
|
||||
|
||||
if fieldValueKind == reflect.Struct {
|
||||
fieldValue = Map(val.Field(i).Interface())
|
||||
} else {
|
||||
fieldValue = val.Field(i).Interface()
|
||||
}
|
||||
|
||||
result[fieldName] = fieldValue
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
Reference in New Issue
Block a user