cast icon indicating copy to clipboard operation
cast copied to clipboard

Cast to reflect.Value

Open nmiculinic opened this issue 3 years ago • 2 comments

This would be pretty nice building block for reflect type casting; something like:

cast.ToReflectValue(i interface{}, value reflect.Values) error

nmiculinic avatar Aug 09 '21 15:08 nmiculinic

What is reflect.Values and what is its purpose in that function?

What's wrong with just doing v := reflect.ValueOf(i)?

bep avatar Aug 09 '21 16:08 bep

I want to set it. That is for example:

cast.ToReflectValues("10s", x)

would set the x to duration 10s if x is of type duration

nmiculinic avatar Aug 09 '21 18:08 nmiculinic