Golang, string type variable
Is it possible to create a variable with a type from a string?
Example:
I have two types:
type FirstType struct {
...
}
type SecondType struct {
...
}
// also I have a string variable
var1 := "Second"
I want to create a variable with type - String value + "Type"
:
var variable = []var1+"Type" // slice of "SecondType"
The expected result is as in this case:
var variable = []SecondType
Thank!
+3
source to share