0
I started learning Go recently. I want to be able to save one type of data into one variable, and convert another variable to it. I know that 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
for the guy saved in t
?
Do you really need to use the reflect package or do you just want to do a simple type conversion? Wouldn’t that be enough? https://go-tour-br.appspot.com/basics/13
– navossoc
@navossoc The idea is to convert to a type dynamically, which will be saved in the class
– Felipe Nascimento
See if it looks like this: https://goplay.space/#Mxuau0dbmq Anyway, I don’t understand where you’re going with this.
– navossoc