通过名称调用其他包中的方法?

I'm trying to call a method in another package by the name of the method (using the reflect package) but I'm not sure exactly how to do it.

What I'm trying so far is,

reflect.ValueOf(controller).MethodByName(action_name).Call()

(where controller is the other package)

Any ideas?

You can't do this using pkg/reflect. For this to work, packages would need to be first class citizens, which they are not.

Your best bet is to store the functions you want to access in a map[string]interface{} and look up the function in the map:

func Foo() { println("foo?") }

m := map[string]interface{}{
    "foo": Foo
}

f := m["foo"].(func())
f()