doujiangao4229
2012-05-24 17:51在Golang中使用反射获取函数名称
I'm trying to use Go's reflection system to retrieve the name of a function but I get an empty string when calling the Name method on its type. Is this the expected behavior?
This is a simple example of how I approach the problem:
package main
import "fmt"
import "reflect"
func main() {
typ := reflect.TypeOf(main)
name := typ.Name()
fmt.Println("Name of function" + name)
}
- 点赞
- 回答
- 收藏
- 复制链接分享
3条回答
为你推荐
- 在Golang中使用反射获取函数名称
- reflection
- 3个回答