지원 타입 및 로그 추가
This commit is contained in:
@ -133,6 +133,13 @@ type houstonClient struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func unmarshal[T any](val *T, src map[string]string) {
|
func unmarshal[T any](val *T, src map[string]string) {
|
||||||
|
defer func() {
|
||||||
|
r := recover()
|
||||||
|
if r != nil {
|
||||||
|
logger.Error(r)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
argval := reflect.ValueOf(val)
|
argval := reflect.ValueOf(val)
|
||||||
for i := 0; i < argval.Elem().Type().NumField(); i++ {
|
for i := 0; i < argval.Elem().Type().NumField(); i++ {
|
||||||
if !argval.Elem().Type().Field(i).IsExported() {
|
if !argval.Elem().Type().Field(i).IsExported() {
|
||||||
@ -145,6 +152,9 @@ func unmarshal[T any](val *T, src map[string]string) {
|
|||||||
} else if argval.Elem().Field(i).Kind() == reflect.Array || argval.Elem().Field(i).Kind() == reflect.Slice {
|
} else if argval.Elem().Field(i).Kind() == reflect.Array || argval.Elem().Field(i).Kind() == reflect.Slice {
|
||||||
conv := strings.Split(arg, "\n")
|
conv := strings.Split(arg, "\n")
|
||||||
argval.Elem().Field(i).Set(reflect.ValueOf(conv))
|
argval.Elem().Field(i).Set(reflect.ValueOf(conv))
|
||||||
|
} else if argval.Elem().Field(i).Kind() == reflect.Bool {
|
||||||
|
bv, _ := strconv.ParseBool(arg)
|
||||||
|
argval.Elem().Field(i).SetBool(bv)
|
||||||
} else {
|
} else {
|
||||||
argval.Elem().Field(i).SetString(arg)
|
argval.Elem().Field(i).SetString(arg)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user