kos/util/reflection/reflection.go

24 lines
482 B
Go

package reflection
import (
"git.nspix.com/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)
}