spf13 / cast

safe and easy casting from one type to another in Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cast to reflect.Value

nmiculinic opened this issue · comments

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

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

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

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

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