1、代码
package main import "fmt" type Get func(serviceName string) interface{} func get1(serviceName string) interface{} { return serviceName } var a = func(get Get, serviceName string) interface{} { return get(serviceName) } type ServiceMap map[string]Get func main() { fmt.Println(a(get1, "aaa")) var bMap = ServiceMap{"1": get1} fmt.Println(bMap["1"]("bbb")) }
2、输出结果