Suppose I have two package like
-a
-b
a have some methods like this
func TestOne() { //something }
func TestTwo() { //something }
I need to call package a's methods from package b but by only string method name. Like i get the string "TestOne" and calls for the method TestOne(). How can i get that done.
Edit :
I have Read about reflect. but reflect needs an struct and functions be a member of that struct. What if My functions are not member of a struct? just plain methods in a package. and the calling methods and called methods are in different package. Then?
NB. There could be some methods that have parameters as well.
mnagel's answer to the linked question. It should be the second answer from the top at this time. You can use reflect to call functions as long as you have the function's handle, which you can get via a map. You're misinterpreting the fact that you cannot get a free function's handle solely via reflection. As long as you build amap[string]interface{}that returns the functions by name yourself, you can call the function viareflect.ValueOffollowed byValue.CallorValue.CallSlice