I want to merge some similar func code to one func, but every old func is use different type of struct, so i intend to create the model by different string of type. SO i do something like this:
type A struct {
filed string
}
type B struct {
filed string
}
and still C, D, E, F here...(every struct has its own method different with others)
and i want create those type in one place:
create(typeName string) interface {
switch typeName {
case A:
return &A{}
case B:
return &B{}
....(more case than 10 times)
}
}
Then i use the create() here:
model := create("A")
now, model
is type of interface, and no A`s fileds, how would simply to recover the type of model to A