文章目录
基本概念

demo
源码:https://gitee.com/luyue_zhang/reflect_fast
reflect 实现简版json.Marshal、json.UnMarshal
使用场景
db中字段列存储json数据
演示
test文件位置:https://gitee.com/luyue_zhang/reflect_fast/blob/master/test/marshal_test.go

反射实现方法调用
使用场景
演示
test文件位置:https://gitee.com/luyue_zhang/reflect_fast/blob/master/test/reflect_method_test.go

使用反射设置值
使用场景
演示
test文件位置:https://gitee.com/luyue_zhang/reflect_fast/blob/master/test/set_value_test.go

.Elem()含义
.Elem()用于获取指针、切片、数组或映射map的基础类型
- 对于指针
*test,.Elem()返回test - 对于切片
[]*test, .Elem()返回*test// 元素类型 - 对于数组
[5]test, .Elem()返回test// 元素类型 - 对于映射
map[string]test, .Elem()返回test
1794

被折叠的 条评论
为什么被折叠?



