Go语言中文网 为您找到相关结果 1

golang-反射机制

1,写数据库dao层的时候用到了反射机制。在反射的时候要注意你的对象时指针还是结构体这样区别也很大。以下接受几种常用的放射方法 reflect.type of package main import ( "fmt" "reflect" ) type hehe struct { NameFile string "PrimaryKey" age int } func main() { hehe := &hehe{"ssssssssssss", 33} yingShe(hehe) } func yingShe(obj interface{}) { hehe := &hehe{"ssssssssssss", 22} for i := 0; i < reflect.TypeOf(obj).Elem()...阅读全文

博文 2016-04-10 20:00:01 shuanger_