Skip to content

Commit f3772b8

Browse files
committed
debug: 空数据指针vs nil
1 parent 84bba70 commit f3772b8

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

debug/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ Debug 调试神技
9292
- 遍历修改列表问题。一边遍历,一边修改可能会使得迭代器失效而出错,最好不要遍历的时候修改列表。
9393
- 遍历修改元素值问题。这一点 go 和 python 表现不同,go 比如你去循环一个 `[]Struct` 是无法修改每个元素的,go 会拷贝每一个元素值,需要通过下标或者指针修改
9494
- 影子变量(shadow)。很多语言同名的局部作用域变量会隐藏外部作用域变量,最好不要同名冲突,否则可能不是期望结果。建议使用go vet/go-nyet 之类的静态检查工具检查
95+
- 空数据和nil。注意在 go 里空数据指针比如 &SomeStruc{} 和 nil 序列化的结果是不同的,注意序列化之后的差别
9596

9697
函数错误
9798
~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)