kos/util/reflection/reflection.go

24 lines
481 B
Go

package reflection
import (
"git.nobla.cn/golang/kos/util/reflect"
reflectpkg "reflect"
)
func Setter[T string | int | int64 | float64 | any](hacky any, variables map[string]T) (err error) {
for k, v := range variables {
if err = Set(hacky, k, v); err != nil {
return err
}
}
return
}
func Assign(s reflectpkg.Value, v any) error {
return reflect.Assign(s, v)
}
func Set(hacky any, field string, value any) (err error) {
return reflect.Set(hacky, field, value)
}