计算机学习

您现在的位置是:首页 > go > 正文

go

reflect.TypeOf()获取变量类型

hhb2022-07-23go108
type student struct {   Name string   Age 
type student struct {
   Name string
   Age int64
}

ptr1:="ssddd"
ptr2:=map[string][]string{}
ptr3:=student{

}
fmt.Printf("%v\n",reflect.TypeOf(ptr1))
fmt.Printf("%v\n",reflect.TypeOf(ptr2))
fmt.Printf("%v\n",reflect.TypeOf(ptr3))

打印结果:

string

map[string][]string

main.student


发表评论

评论列表

  • 这篇文章还没有收到评论,赶紧来抢沙发吧~