This question already has an answer here:
For example, I have a type called Foo
, and I'd like to know if I am able to do things like this in Golang:
type Foo struct { /* some fields */ }
func GetObj(myType string) interface{} {
// code that will return an object with type myType
}
fooObj := GetObj("Foo")
</div>