企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## 一、实例 ~~~ package main import ( "reflect" "fmt" ) //结构体 type User struct { Id int Name string Age int } type Boy struct { User Addr string } func main() { m := Boy{User{1,"zhangsan",20},"sz"} //获取对象信息 t := reflect.TypeOf(m) //#号会把反射的结构体的详情打印 fmt.Printf("%#v\n",t.Field(0)) } ~~~ 打印结果: reflect.StructField{Name:"User", PkgPath:"", Type:(*reflect.rtype)(0x8ed280), Tag:"", Offset:0x0, Index:[]int{0}, Anonymous:true}