Convert a variable to a reflect.Type

0

I started learning Go recently. I want to be able to save a data type to a variable, and convert another variable to it. I know one way to save a data type is by using reflect.Type .

i := 5
t := reflect.TypeOf(i)
var f float32 = 4.2

But how do I convert f to the type saved in t ?

    
asked by anonymous 29.09.2017 / 02:40

0 answers