There is no central registry of types in Go, so what you ask is impossible in the general case.
You could build up your own registry by hand to support such a feature using a map from strings to reflect.Type values corresponding to each type. For instance:
var typeRegistry = make(map[string]reflect.Type)
func init() {
myTypes := []interface{}{MyString{}}
for _, v := range myTypes {
// typeRegistry["MyString"] = reflect.TypeOf(MyString{})
typeRegistry[fmt.Sprintf("%T", v)] = reflect.TypeOf(v)
}
}
You can then create instances of the types like so:
func makeInstance(name string) interface{} {
v := reflect.New(typeRegistry[name]).Elem()
// Maybe fill in fields here if necessary
return v.Interface()
}