package main
import (
"fmt"
"reflect"
)
var funcMap = map[string]interface{}{
"Hello": Hello,
}
func Hello(name string) {
fmt.Printf("Hello, %s!\n", name)
}
func main() {
nameFunc := "Hello"
if fn, ok := funcMap[nameFunc]; ok {
funcValue := reflect.ValueOf(fn)
args := []reflect.Value{reflect.ValueOf("Gopher")}
funcValue.Call(args)
} else {
fmt.Println("Function not found!")
}
}