Skip to content

Commit d802a7a

Browse files
committed
debug: go map concurrent read/write error
1 parent 8377b94 commit d802a7a

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

debug/index.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ Debug 调试技巧
7474
- 遍历修改列表问题。一边遍历,一边修改可能会使得迭代器失效而出错,最好不要遍历的时候修改列表。
7575
- 遍历修改元素值问题。这一点 go 和 python 表现不同,go 比如你去循环一个 []Struct 是无法修改每个元素的,go 会拷贝每一个元素值,需要通过下标或者指针修改
7676

77+
并发问题
78+
~~~~~~~~~~~~~~~~~~~~~~
79+
- 线程安全。如果不是线程安全的操作,应该通过加锁等方式做数据同步。比如 go 里边如果并发读写 map 程序会出错
80+
7781
日志错误
7882
~~~~~~~~~~~~~~~~~~~~~~
7983
- 日志级别错误。线上使用了 debug 级别,可能导致日志打满,如果没有滚动日志可能会导致服务器磁盘打满。一定要注意不同环境日志级别

0 commit comments

Comments
 (0)