for-loop 与 json.Unmarshal 性能分析概要
for-loop 与 json.Unmarshal 性能分析概要 在项目中,常常会遇到循环交换赋值的数据处理场景,尤其是 RPC,数据交互格式要转为 Protobuf,赋值是无法避免的。一般会有如下几种做法: for for range json.Marshal/Unmarshal 这时候又面临 “选择困难症”,用哪个好?又想代码量少,又担心性能有没有影响啊... 为了弄清楚这个疑惑,接下来将分别编写三种使用场景。来简单看看它们的性能情况,看看谁更 “好” 功能代码 ... type Person struct { Name string `json:"name"` Age int `json:"age"` Avatar string `json:"avatar"` Type string ...阅读全文