2021
08-31
08-31
Go遍历struct,map,slice的实现
目录遍历结构体遍历切片遍历MapGolangjson序列化(struct,int,map,slice)遍历结构体如何实现遍历结构体字段?好吧,言归正传!举个例子:demo1:packagemainimport("fmt""reflect")typeStudentstruct{namestringageint}funcmain(){v:=reflect.ValueOf(Student{"乔峰",29})count:=v.NumField()fori:=0;i<count;i++{f:=v.Field(i)//字段值switchf.Kind(){...
继续阅读 >