防御式编程:规避 nil panic 与切片别名陷阱
在 Go 的线上故障中,nil panic 是最常见的类别之一。比显式崩溃更难定位的,是不报错的错误:两个切片共享同一个底层数组时,下游修改一个元素,上游的统计数据随之改变,全程没有任何异常提示。这类缺陷的成因是确定性的,但由于不显式报错,排查成本远高于 panic。
10 min read
Loading…
Quote of the day · October 26 · 关于意义 · Rick and Morty
Nobody exists on purpose. Nobody belongs anywhere. Everybody's gonna die. Come watch TV?
Notes on Agent runtimes — design decisions laid open: why it is this way, what it costs, and when it stops being true.