如何将字符串转换为函数名称

I need to read data from XML file and convert that into a function in golang. Because in golang I need this function to be used in mux.NewRouter().HandleFunc("/url",functionName). I need a way to convert this string which read from XML file to a function name to use as functionName.

If you register all the functions that you want to call as methods on a type then you can do something like the following.

type Foo struct{}

func (Foo) Bar() {
    fmt.Println("foobar")
}

...

f := reflect.ValueOf(Foo{}).MethodByName("Bar").Interface().(func())
f()

Where you reflect the struct that the methods are on and then get the method's interface value and type assert it back to it's func signature.

Runnable example: https://play.golang.org/p/m2nywmeD0Y