kos/util/reflection/reflection.go

17 lines
376 B
Go
Raw Normal View History

2023-06-30 14:16:16 +08:00
package reflection
import "git.nspix.com/golang/kos/util/reflect"
2023-08-16 09:57:42 +08:00
func Setter[T string | int | int64 | float64 | any](hacky any, variables map[string]T) (err error) {
2023-06-30 14:16:16 +08:00
for k, v := range variables {
if err = Set(hacky, k, v); err != nil {
return err
}
}
return
}
2023-08-16 09:57:42 +08:00
func Set(hacky any, field string, value any) (err error) {
2023-06-30 14:16:16 +08:00
return reflect.Set(hacky, field, value)
}