I've got function that returns struct instance depending on argument it takes
func Factory(s string) interface{} {
if s == 'SomeType' {
return SomeType{}
} else if s == 'AnotherType' {
return AnotherType{}
}
}
this solution is good if I have a couple of structs to return but it's getting ugly if there are a lot of them, can I do it other way? Is there idiomatic way to do this?