TENX-S / blog_comment

0 stars 0 forks source link

for-range的坑 | Ares Andrew #4

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

for-range的坑 | Ares Andrew

起因 在写毕设时碰到了这样一个问题:为 Post 数组中每个 Post 的 UUID 值生成一个QRCode,听起来很简单对吧,for-range遍历就好了。生成QRCode的函数如下所示: func (p *Post) initQRCode() { ... } 这么写的本意是想避免每次调用时产生的一次内存拷贝,所以就用了指针接收者,可是运行时却发现所有的QRCod

https://ares.zone/tech/2022-04/for-range%E7%9A%84%E5%9D%91/

scallionCC commented 2 years ago

呱呱呱