![]() ``` func foo() error { defer func() { if err != nil { ... } }() ... } ``` use defer func to do something when err not nil, if foo() not use named error, `err != nil` can not catch all errors, since when err re-defined in if condition, it is a new variable. Signed-off-by: Ace-Tang <aceapril@126.com> |
||
---|---|---|
.. | ||
check_test.go | ||
check.go | ||
overlay_test.go | ||
overlay.go |