errors.Join
已收录文章:2篇
-
Golang · Go教程 | 3星期前 | 错误处理 · Go教程 · errors.Join · errors.Is · Go 1.20 · 错误包装 errors.Is errors.As Go errors.Join 多错误处理 Go 1.20Go 1.20 的 errors.Join 可以把多条错误合并为一个错误值,同时保留 errors.Is 和 errors.As 的判断能力。本文用批量关闭资源、并行任务汇总等场景说明该怎么用,以及哪些时候不该把错误一股脑拼在一起。431 收藏
-
Golang · Go教程 | 1个月前 | 单元测试 · 错误处理 · Go教程 · errors.Join · errors.Is · errors.Is Go错误处理 Go教程 errors.Join 多错误返回 批量校验Go 里遇到批量校验、批量关闭资源、批量处理任务时,不必只返回第一个错误。errors.Join 可以把多个 error 合成一个 error,同时保留 errors.Is、errors.As 的匹配能力,并且对 nil 有明确兼容规则。352 收藏