GO Multiple Pointers -
i'm trying create function receives multiple types of struct , add pointer values function.
example:
type model1 struct { name string } type model2 struct { type bool } func myfunc(value ...interface{}) { otherfunc(value...) } func main() { myfunc( new(model), new(mode2) ); }
the problem otherfunc
allow &value, &value, etc
parameter. have way pass values otherfunc(&value...)
?
i'm not sure solve problem entirely however, exact thing requested feature in language. have use composite-literal syntax instantiation instead of new. pass pointers; myfunc( &model{}, &mode2{} )
thing is, you're still going dealing interface{}
within myfunc
i'm not sure able call otherfunc
without unboxing (would type assertion if want technical).
Comments
Post a Comment